aboutsummaryrefslogtreecommitdiffstats
path: root/qt-ui/divelistview.cpp
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2014-02-10 08:17:19 -0800
committerGravatar Dirk Hohndel <dirk@hohndel.org>2014-02-10 08:20:53 -0800
commit2f2c9e371ceeba4cf45575b5a30815bcd562f853 (patch)
tree8fcde3c2f4d1e3f4b6a69c82ebd5552abae70601 /qt-ui/divelistview.cpp
parent31c45b8c4ceca669b36706814ec7379cacd685f0 (diff)
downloadsubsurface-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.cpp9
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;