[PATCH] QFileSystemEngine::canonicalName (Unix): clean up control-flow
authorFabian Kosmale <fabian.kosmale@qt.io>
Mon, 14 Feb 2022 09:29:24 +0000 (10:29 +0100)
committerPino Toscano <pino@debian.org>
Sat, 3 Sep 2022 06:15:09 +0000 (07:15 +0100)
commit84713a86cc183c11a526ab63a278da9346ef19a0
treebc34349b9a0d984f3dee3594f87e75a05981c40e
parent4850d15b8f3d9b78f16e70dcca0326fac6097db1
[PATCH] QFileSystemEngine::canonicalName (Unix): clean up control-flow

When passing a nullptr to realpath, it will allocate memory. That memory
has to be freed (with free) later to avoid a leak, which we so far
didn't.
This patch ensures that we always clean up the memory by using a
unique_ptr. As a drive-by, clean up the control-flow:
- Always pass either the stack buffer or nullptr to realpath.
- Rely on realpath returning nullptr in the error case.
Lastly, fix a few coding-style issues.

Change-Id: Ia906df77324020c267b087ec52a9a6c47aaa2a59
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Gbp-Pq: Name upstream_QFileSystemEngine-canonicalName-Unix-clean-up-contro.patch
src/corelib/io/qfilesystemengine_unix.cpp