mirror of
https://github.com/subsurface/subsurface.git
synced 2025-01-19 14:25:27 +00:00
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:
parent
31c45b8c4c
commit
2f2c9e371c
1 changed files with 6 additions and 3 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Reference in a new issue