From: Lutz M. <lu...@us...> - 2004-08-26 20:08:26
|
Update of /cvsroot/libexif/libexif/libexif In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18453/libexif Modified Files: exif-entry.c exif-loader.c exif-utils.c Log Message: 2004-08-26 Lutz Mueller <lu...@us...> Suggestions from Angela Wrobel <Ang...@gm...>: * libexif/exif-entry.c * libexif/exif-loader.c * libexif/exif-utils.c * olympus/exif-mnote-data-olympus.c * pentax/exif-mnote-data-pentax.c: Check if malloc returned NULL. Index: exif-utils.c =================================================================== RCS file: /cvsroot/libexif/libexif/libexif/exif-utils.c,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- exif-utils.c 15 Dec 2002 11:41:11 -0000 1.5 +++ exif-utils.c 26 Aug 2004 20:08:09 -0000 1.6 @@ -26,6 +26,7 @@ static ExifSShort exif_get_sshort (const unsigned char *buf, ExifByteOrder order) { + if (!buf) return 0; switch (order) { case EXIF_BYTE_ORDER_MOTOROLA: return ((buf[0] << 8) | buf[1]); @@ -46,6 +47,7 @@ void exif_set_short (unsigned char *b, ExifByteOrder order, ExifShort value) { + if (!b) return; switch (order) { case EXIF_BYTE_ORDER_MOTOROLA: b[0] = (unsigned char) (value >> 8); @@ -61,6 +63,7 @@ ExifSLong exif_get_slong (const unsigned char *b, ExifByteOrder order) { + if (!b) return 0; switch (order) { case EXIF_BYTE_ORDER_MOTOROLA: return ((b[0] << 24) | (b[1] << 16) | (b[2] << 8) | b[3]); @@ -75,6 +78,7 @@ void exif_set_slong (unsigned char *b, ExifByteOrder order, ExifSLong value) { + if (!b) return; switch (order) { case EXIF_BYTE_ORDER_MOTOROLA: b[0] = (unsigned char) (value >> 24); @@ -108,8 +112,8 @@ { ExifSRational r; - r.numerator = exif_get_slong (buf, order); - r.denominator = exif_get_slong (buf + 4, order); + r.numerator = buf ? exif_get_slong (buf, order) : 0; + r.denominator = buf ? exif_get_slong (buf + 4, order) : 0; return (r); } @@ -119,8 +123,8 @@ { ExifRational r; - r.numerator = exif_get_long (buf, order); - r.denominator = exif_get_long (buf + 4, order); + r.numerator = buf ? exif_get_long (buf, order) : 0; + r.denominator = buf ? exif_get_long (buf + 4, order) : 0; return (r); } @@ -129,6 +133,7 @@ exif_set_rational (unsigned char *buf, ExifByteOrder order, ExifRational value) { + if (!buf) return; exif_set_long (buf, order, value.numerator); exif_set_long (buf + 4, order, value.denominator); } @@ -137,6 +142,7 @@ exif_set_srational (unsigned char *buf, ExifByteOrder order, ExifSRational value) { + if (!buf) return; exif_set_slong (buf, order, value.numerator); exif_set_slong (buf + 4, order, value.denominator); } Index: exif-entry.c =================================================================== RCS file: /cvsroot/libexif/libexif/libexif/exif-entry.c,v retrieving revision 1.54 retrieving revision 1.55 diff -u -d -r1.54 -r1.55 --- exif-entry.c 27 May 2004 17:11:40 -0000 1.54 +++ exif-entry.c 26 Aug 2004 20:08:09 -0000 1.55 @@ -46,14 +46,10 @@ ExifEntry *e; e = malloc (sizeof (ExifEntry)); - if (!e) - return NULL; + if (!e) return NULL; memset (e, 0, sizeof (ExifEntry)); e->priv = malloc (sizeof (ExifEntryPrivate)); - if (!e->priv) { - free (e); - return NULL; - } + if (!e->priv) { free (e); return NULL; } memset (e->priv, 0, sizeof (ExifEntryPrivate)); e->priv->ref_count = 1; @@ -798,7 +794,7 @@ e->format = EXIF_FORMAT_LONG; e->size = exif_format_get_size (e->format) * e->components; e->data = malloc (e->size); - memset (e->data, 0, e->size); + if (e->data) memset (e->data, 0, e->size); break; /* SHORT, 1 component, no default */ @@ -892,7 +888,7 @@ e->format = EXIF_FORMAT_SRATIONAL; e->size = exif_format_get_size (e->format) * e->components; e->data = malloc (e->size); - memset (e->data, 0, e->size); + if (e->data) memset (e->data, 0, e->size); break; /* RATIONAL, 1 component, no default */ @@ -913,7 +909,7 @@ e->format = EXIF_FORMAT_RATIONAL; e->size = exif_format_get_size (e->format) * e->components; e->data = malloc (e->size); - memset (e->data, 0, e->size); + if (e->data) memset (e->data, 0, e->size); break; /* RATIONAL, 1 component, default 72/1 */ @@ -934,7 +930,7 @@ e->format = EXIF_FORMAT_RATIONAL; e->size = exif_format_get_size (e->format) * e->components; e->data = malloc (e->size); - memset (e->data, 0, e->size); + if (e->data) memset (e->data, 0, e->size); break; /* RATIONAL, 6 components */ Index: exif-loader.c =================================================================== RCS file: /cvsroot/libexif/libexif/libexif/exif-loader.c,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- exif-loader.c 20 May 2004 10:50:35 -0000 1.7 +++ exif-loader.c 26 Aug 2004 20:08:09 -0000 1.8 @@ -62,7 +62,7 @@ { int i, len_remain; - if (!eld) return 0; + if (!eld || !buf || !len) return 0; if (eld->state == EL_FAILED) return 0; if (eld->size && eld->bytes_read == eld->size) return 0; @@ -144,6 +144,7 @@ if (eld->state == EL_EXIF_FOUND && len_remain > 0) { if (eld->buf == NULL) { eld->buf = malloc (sizeof (unsigned char) * eld->size); + if (!eld->buf) return 0; eld->bytes_read = 0; } @@ -169,9 +170,10 @@ { ExifLoader *loader = malloc (sizeof (ExifLoader)); + if (!loader) return NULL; memset (loader, 0, sizeof (ExifLoader)); loader->ref_count = 1; - + return loader; } |