Correct Unix QStorageInfo's QStorageIterator::next()'s loop logic
The loop was accepting any line with at least three entries, but the code that then used this line needed four entries. At the same time, the loop's check had to be repeated, in rearranged form, after the loop, to handle some failing cases. Restructuring the loop, and demanding at least four entries, fixes all of this, although care must be taken about the virtual file-system lying about .atEnd(). [ChangeLog][QtCore][QStorageInfo] Fixed a bug on Android that could cause QStorageInfo to skip some filesystems (if the mount table is a virtual file and contains any short lines) or crash (if the mount table contains any 3-field lines). Change-Id: I1c2674372d0d0b7d16937de4345a910bc7d6e0ad Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io> Reviewed-by: Ivan Komissarov <ABBAPOH@gmail.com> Reviewed-by: Johannes Rosenqvist <xeroc81@gmail.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
parent
3303715099
commit
41f737a12c
@ -342,13 +342,14 @@ inline bool QStorageIterator::isValid() const
|
||||
inline bool QStorageIterator::next()
|
||||
{
|
||||
QList<QByteArray> data;
|
||||
// If file is virtual, file.readLine() may succeed even when file.atEnd().
|
||||
do {
|
||||
const QByteArray line = file.readLine();
|
||||
data = line.split(' ');
|
||||
} while (data.count() < 3 && !file.atEnd());
|
||||
|
||||
if (file.atEnd() && data.count() <= 3)
|
||||
if (line.isEmpty() && file.atEnd())
|
||||
return false;
|
||||
data = line.split(' ');
|
||||
} while (data.count() < 4);
|
||||
|
||||
m_device = data.at(0);
|
||||
m_rootPath = data.at(1);
|
||||
m_fileSystemType = data.at(2);
|
||||
|
Loading…
Reference in New Issue
Block a user