diff options
author | Milian Wolff <milian.wolff@kdab.com> | 2017-04-12 17:50:37 +0200 |
---|---|---|
committer | Milian Wolff <milian.wolff@kdab.com> | 2017-04-13 09:40:40 +0000 |
commit | b403dc3a48016bfb2c4787e4039485576ab1faee (patch) | |
tree | 3dfc6d72da105569e7223ac26799b98249adfaee | |
parent | 74a1fa8cf0e3e2050aa155591d6a23f08d9ecce6 (diff) |
Return early when reading the file attributes or features failed
When this happens, it is an indicator for a broken file and we
don't even need to go in and parse its contents.
Change-Id: If96e0b1e9fed2cb1069b6d3f4bfc03193321c132
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
-rw-r--r-- | app/main.cpp | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/app/main.cpp b/app/main.cpp index eebb684..4b0e6a6 100644 --- a/app/main.cpp +++ b/app/main.cpp @@ -234,8 +234,16 @@ int main(int argc, char *argv[]) QObject::connect(&header, &PerfHeader::finished, [&]() { if (!header.isPipe()) { const qint64 filePos = infile->pos(); - attributes.read(infile.data(), &header); - features.read(infile.data(), &header); + if (!attributes.read(infile.data(), &header)) { + qWarning() << "Failed to read attributes"; + qApp->exit(DataError); + return; + } + if (!features.read(infile.data(), &header)) { + qWarning() << "Failed to read features"; + qApp->exit(DataError); + return; + } infile->seek(filePos); // first send features, as it may contain better event descriptions |