aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorghost <andreas.monzner@multimedia-labs.de>2011-04-05 15:55:38 +0200
committerghost <andreas.monzner@multimedia-labs.de>2011-04-05 15:55:38 +0200
commitbd726aa0c91dc08545187dfe4e379948e0129d92 (patch)
tree2a93b9a3ae9c3152b25df2f59da2adf66ca9c94c
parent8c15179ddabe8fb889ddee7a4629530cbb6c7964 (diff)
downloadenigma2-bd726aa0c91dc08545187dfe4e379948e0129d92.tar.gz
enigma2-bd726aa0c91dc08545187dfe4e379948e0129d92.zip
fixed DecodeExif error handling.. this should fix a FD leak
fixes bug #599
-rw-r--r--lib/gdi/picexif.cpp31
1 files changed, 20 insertions, 11 deletions
diff --git a/lib/gdi/picexif.cpp b/lib/gdi/picexif.cpp
index f9e8055f..94d581cf 100644
--- a/lib/gdi/picexif.cpp
+++ b/lib/gdi/picexif.cpp
@@ -90,9 +90,9 @@ void Cexif::ClearExif()
bool Cexif::DecodeExif(const char *filename, int Thumb)
{
+ bool ret = false;
FILE * hFile = fopen(filename, "r");
- if(!hFile) return false;
-
+ if(!hFile) return ret;
m_exifinfo = new EXIFINFO;
memset(m_exifinfo,0,sizeof(EXIFINFO));
@@ -107,7 +107,8 @@ bool Cexif::DecodeExif(const char *filename, int Thumb)
int a = fgetc(hFile);
strcpy(m_szLastError,"EXIF-Data not found");
- if (a != 0xff || fgetc(hFile) != M_SOI) return false;
+ if (a != 0xff || fgetc(hFile) != M_SOI)
+ goto decode_exif_out;
for(;;)
{
@@ -117,7 +118,8 @@ bool Cexif::DecodeExif(const char *filename, int Thumb)
if (SectionsRead >= MAX_SECTIONS)
{
- strcpy(m_szLastError,"Too many sections in jpg file"); return false;
+ strcpy(m_szLastError,"Too many sections in jpg file");
+ goto decode_exif_out;
}
for (a=0;a<7;a++)
@@ -127,13 +129,15 @@ bool Cexif::DecodeExif(const char *filename, int Thumb)
if (a >= 6)
{
- strcpy(m_szLastError,"too many padding unsigned chars\n"); return false;
+ strcpy(m_szLastError,"too many padding unsigned chars\n");
+ goto decode_exif_out;
}
}
if (marker == 0xff)
{
- strcpy(m_szLastError,"too many padding unsigned chars!"); return false;
+ strcpy(m_szLastError,"too many padding unsigned chars!");
+ goto decode_exif_out;
}
Sections[SectionsRead].Type = marker;
@@ -145,14 +149,16 @@ bool Cexif::DecodeExif(const char *filename, int Thumb)
if (itemlen < 2)
{
- strcpy(m_szLastError,"invalid marker"); return false;
+ strcpy(m_szLastError,"invalid marker");
+ goto decode_exif_out;
}
Sections[SectionsRead].Size = itemlen;
Data = (unsigned char *)malloc(itemlen);
if (Data == NULL)
{
- strcpy(m_szLastError,"Could not allocate memory"); return false;
+ strcpy(m_szLastError,"Could not allocate memory");
+ goto decode_exif_out;
}
Sections[SectionsRead].Data = Data;
@@ -163,7 +169,8 @@ bool Cexif::DecodeExif(const char *filename, int Thumb)
got = fread(Data+2, 1, itemlen-2,hFile);
if (got != itemlen-2)
{
- strcpy(m_szLastError,"Premature end of file?"); return false;
+ strcpy(m_szLastError,"Premature end of file?");
+ goto decode_exif_out;
}
SectionsRead += 1;
@@ -173,7 +180,7 @@ bool Cexif::DecodeExif(const char *filename, int Thumb)
return true;
case M_EOI:
printf("No image in jpeg!\n");
- return false;
+ goto decode_exif_out;
case M_COM:
if (HaveCom)
{
@@ -220,9 +227,11 @@ bool Cexif::DecodeExif(const char *filename, int Thumb)
break;
}
}
+ ret = true;
+decode_exif_out:
fclose(hFile);
- return true;
+ return ret;
}
bool Cexif::process_EXIF(unsigned char * CharBuf, unsigned int length)