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>
This commit is contained in:
Dirk Hohndel 2014-02-10 08:17:19 -08:00
parent 31c45b8c4c
commit 2f2c9e371c

View file

@ -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;