mirror of
https://bitbucket.org/smil3y/kde-playground.git
synced 2025-02-23 18:32:51 +00:00
massif-visualizer: avoid possible null-terminated string issues
Signed-off-by: Ivailo Monev <xakepa10@laimg.moc>
This commit is contained in:
parent
68c82359b0
commit
aefadce667
1 changed files with 3 additions and 3 deletions
|
@ -40,7 +40,7 @@ using namespace Massif;
|
||||||
|
|
||||||
static QByteArray midRef(const QByteArray& line, int offset, int length = -1)
|
static QByteArray midRef(const QByteArray& line, int offset, int length = -1)
|
||||||
{
|
{
|
||||||
return QByteArray::fromRawData(line.data() + offset, length == -1 ? (line.length() - offset) : length);
|
return line.mid(offset, length == -1 ? (line.length() - offset) : length);
|
||||||
}
|
}
|
||||||
|
|
||||||
ParserPrivate::ParserPrivate(Parser* parser, QIODevice* file, FileData* data,
|
ParserPrivate::ParserPrivate(Parser* parser, QIODevice* file, FileData* data,
|
||||||
|
@ -186,7 +186,7 @@ void ParserPrivate::parseFileTimeUnit(const QByteArray& line)
|
||||||
|
|
||||||
void ParserPrivate::parseSnapshot(const QByteArray& line)
|
void ParserPrivate::parseSnapshot(const QByteArray& line)
|
||||||
{
|
{
|
||||||
VALIDATE(line, line == "#-----------")
|
VALIDATE(line, line.startsWith("#-----------"))
|
||||||
|
|
||||||
// snapshot=N
|
// snapshot=N
|
||||||
QByteArray nextLine = readLine();
|
QByteArray nextLine = readLine();
|
||||||
|
@ -195,7 +195,7 @@ void ParserPrivate::parseSnapshot(const QByteArray& line)
|
||||||
uint number = midRef(nextLine, 9).toUInt(&ok);
|
uint number = midRef(nextLine, 9).toUInt(&ok);
|
||||||
VALIDATE(nextLine, ok)
|
VALIDATE(nextLine, ok)
|
||||||
nextLine = readLine();
|
nextLine = readLine();
|
||||||
VALIDATE(nextLine, nextLine == "#-----------")
|
VALIDATE(nextLine, nextLine.startsWith("#-----------"))
|
||||||
|
|
||||||
m_snapshot = new SnapshotItem;
|
m_snapshot = new SnapshotItem;
|
||||||
m_data->addSnapshot(m_snapshot);
|
m_data->addSnapshot(m_snapshot);
|
||||||
|
|
Loading…
Add table
Reference in a new issue