From: Jan P. <pa...@us...> - 2004-05-11 15:15:44
|
Update of /cvsroot/libexif/libexif/libexif In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18752 Modified Files: exif-data.c Log Message: A fix of storing maker note on save. If the new mnote was longer than in the original file, the created file was corrupted. If it was shorter than originally, random rubbish was stored (could be viewed also as "padding"). Index: exif-data.c =================================================================== RCS file: /cvsroot/libexif/libexif/libexif/exif-data.c,v retrieving revision 1.38 retrieving revision 1.39 diff -u -d -r1.38 -r1.39 --- exif-data.c 10 May 2004 12:29:48 -0000 1.38 +++ exif-data.c 11 May 2004 15:15:26 -0000 1.39 @@ -161,6 +161,17 @@ data->priv->order, (ExifShort) e->tag); exif_set_short (*d + 6 + offset + 2, data->priv->order, (ExifShort) e->format); + + /* If this is the maker note tag, update it. */ + if ((e->tag == EXIF_TAG_MAKER_NOTE) && data->priv->md) { + free (e->data); + e->data = NULL; + e->size = 0; + exif_mnote_data_set_offset (data->priv->md, *ds - 6); + exif_mnote_data_save (data->priv->md, &e->data, &e->size); + e->components = e->size; + } + exif_set_long (*d + 6 + offset + 4, data->priv->order, e->components); @@ -172,23 +183,14 @@ if (!s) return; if (s > 4) { + doff = *ds - 6; *ds += s; *d = realloc (*d, sizeof (char) * *ds); - doff = *ds - 6 - s; exif_set_long (*d + 6 + offset + 8, data->priv->order, doff); } else doff = offset + 8; - /* If this is the maker note tag, update it. */ - if ((e->tag == EXIF_TAG_MAKER_NOTE) && data->priv->md) { - free (e->data); - e->data = NULL; - e->size = 0; - exif_mnote_data_set_offset (data->priv->md, doff); - exif_mnote_data_save (data->priv->md, &e->data, &e->size); - } - /* Write the data. Fill unneeded bytes with 0. */ memcpy (*d + 6 + doff, e->data, e->size); if (s < 4) memset (*d + 6 + doff + s, 0, (4 - s)); @@ -666,7 +668,7 @@ } else { char value[7]; em = exif_data_get_entry (data, EXIF_TAG_MAKE); - /* Pentax & some variant of Nikon */ + /* Pentax & some variant of Nikon */ if ((e->size >= 2) && (e->data[0] == 0x00) && (e->data[1] == 0x1b)) { if (em && !strnicmp (exif_entry_get_value (em, value, sizeof(value)), "Nikon", 5)) { |