QStorageInfo: fix use-after-move
Coverity complained about a use of the moved-from (in the first line of the loop) `info` object in subsequent lines. This specific instance is harmless, because the field being accesssed is a scalar and the move SMFs are the default ones, so the field isn't actually changed when the struct is moved from. Still, to silence Coverity and to guide other attentive readers of the code, take a copy of the field before moving from the struct, and use the copy's value after the move. Amendsbb10ddc39eb3a4. Amends3e330a79ec. Pick-to: 6.7 Coverity-Id: 444199 Change-Id: I26ea8669f27124fb2567b16d803d47ab439f1e41 Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
parent
25652c2819
commit
ae8031b5e7
|
|
@ -268,13 +268,14 @@ QList<QStorageInfo> QStorageInfoPrivate::mountedVolumes()
|
|||
|
||||
QList<QStorageInfo> volumes;
|
||||
for (MountInfo &info : infos) {
|
||||
const auto infoStDev = info.stDev;
|
||||
QStorageInfoPrivate d(std::move(info));
|
||||
d.retrieveVolumeInfo();
|
||||
if (d.bytesTotal <= 0 && d.rootPath != u'/')
|
||||
continue;
|
||||
if (info.stDev != deviceIdForPath(d.rootPath))
|
||||
if (infoStDev != deviceIdForPath(d.rootPath))
|
||||
continue; // probably something mounted over this mountpoint
|
||||
d.name = labelForDevice(d, info.stDev);
|
||||
d.name = labelForDevice(d, infoStDev);
|
||||
volumes.emplace_back(QStorageInfo(*new QStorageInfoPrivate(std::move(d))));
|
||||
}
|
||||
return volumes;
|
||||
|
|
|
|||
Loading…
Reference in New Issue