diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2014-02-10 08:17:19 -0800 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2014-02-10 08:20:53 -0800 |
commit | 2f2c9e371ceeba4cf45575b5a30815bcd562f853 (patch) | |
tree | 8fcde3c2f4d1e3f4b6a69c82ebd5552abae70601 /qt-ui/divelistview.cpp | |
parent | 31c45b8c4ceca669b36706814ec7379cacd685f0 (diff) | |
download | subsurface-2f2c9e371ceeba4cf45575b5a30815bcd562f853.tar.gz |
Don't ignore the return values from readfile and EXIF parser
If readfile fails it already frees its buffer.
If the parsing failed we shouldn't use the data in the structure.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui/divelistview.cpp')
-rw-r--r-- | qt-ui/divelistview.cpp | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/qt-ui/divelistview.cpp b/qt-ui/divelistview.cpp index 014f00583..43f0b1c38 100644 --- a/qt-ui/divelistview.cpp +++ b/qt-ui/divelistview.cpp @@ -804,7 +804,6 @@ void DiveListView::loadImages() { struct memblock mem; EXIFInfo exif; - int code; time_t imagetime; QStringList fileNames = QFileDialog::getOpenFileNames(this, tr("Open Image Files"), lastUsedImageDir(), tr("Image Files (*.jpg *.jpeg *.pnm *.tif *.tiff)")); @@ -819,9 +818,13 @@ void DiveListView::loadImages() for (int i = 0; i < fileNames.size(); ++i) { struct tm tm; int year, month, day, hour, min, sec; - readfile(fileNames.at(i).toUtf8().data(), &mem); - code = exif.parseFrom((const unsigned char *) mem.buffer, (unsigned) mem.size); + int retval; + if (readfile(fileNames.at(i).toUtf8().data(), &mem) <= 0) + continue; + retval = exif.parseFrom((const unsigned char *) mem.buffer, (unsigned) mem.size); free(mem.buffer); + if (retval != PARSE_EXIF_SUCCESS) + continue; sscanf(exif.DateTime.c_str(), "%d:%d:%d %d:%d:%d", &year, &month, &day, &hour, &min, &sec); tm.tm_year = year; tm.tm_mon = month - 1; |