From bb49d2ec026d72db8d5ae678605d6fb9f94a9e0f Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Mon, 9 Aug 2021 18:26:59 +0200 Subject: [PATCH] Correct QStorageIterator::next()'s use of qstrtoll() The end-pointer out-parameter of qstrtoll() is set to the start of the subject string on failure, never to nullptr; and this only happens when ok gets set false in any case, so there's no need to check for it as well as checking ok. Change-Id: I852a77a2398ffdcd5cb0671a586362cd578b6df4 Reviewed-by: Thiago Macieira --- src/corelib/io/qstorageinfo_unix.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/corelib/io/qstorageinfo_unix.cpp b/src/corelib/io/qstorageinfo_unix.cpp index 6845a24838..6bb1978970 100644 --- a/src/corelib/io/qstorageinfo_unix.cpp +++ b/src/corelib/io/qstorageinfo_unix.cpp @@ -1,5 +1,6 @@ /**************************************************************************** ** +** Copyright (C) 2021 The Qt Company Ltd. ** Copyright (C) 2014 Ivan Komissarov ** Copyright (C) 2016 Intel Corporation. ** Contact: https://www.qt.io/licensing/ @@ -488,21 +489,21 @@ inline bool QStorageIterator::next() mnt.mnt_passno = 0; mnt.mount_id = qstrtoll(ptr, const_cast(&ptr), 10, &ok); - if (!ptr || !ok) + if (!ok) return false; int parent_id = qstrtoll(ptr, const_cast(&ptr), 10, &ok); Q_UNUSED(parent_id); - if (!ptr || !ok) + if (!ok) return false; int rdevmajor = qstrtoll(ptr, const_cast(&ptr), 10, &ok); - if (!ptr || !ok) + if (!ok) return false; if (*ptr != ':') return false; int rdevminor = qstrtoll(ptr + 1, const_cast(&ptr), 10, &ok); - if (!ptr || !ok) + if (!ok) return false; mnt.rdev = makedev(rdevmajor, rdevminor);