changeset 4194:1ee48928656b

Makes id3_field_finish to reset all the data that is requested. (Bugzilla #22)
author Jussi Judin <jjudin+audacious@iki.fi>
date Thu, 17 Jan 2008 17:17:47 -0600
parents f6da5b8d401e
children 2b5ea5d4a63e
files src/libid3tag/field.c
diffstat 1 files changed, 22 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/src/libid3tag/field.c	Thu Jan 17 03:40:55 2008 +0200
+++ b/src/libid3tag/field.c	Thu Jan 17 17:17:47 2008 -0600
@@ -120,36 +120,48 @@
 
   case ID3_FIELD_TYPE_LATIN1:
   case ID3_FIELD_TYPE_LATIN1FULL:
-    if (field->latin1.ptr)
+    if (field->latin1.ptr) {
       free(field->latin1.ptr);
+      field->latin1.ptr = NULL;
+    }
     break;
 
   case ID3_FIELD_TYPE_LATIN1LIST:
-    for (i = 0; i < field->latin1list.nstrings; ++i)
-      free(field->latin1list.strings[i]);
+    if (field->latin1list.strings) {
+      for (i = 0; i < field->latin1list.nstrings; ++i)
+        free(field->latin1list.strings[i]);
 
-    if (field->latin1list.strings)
       free(field->latin1list.strings);
+      field->latin1list.nstrings = 0;
+      field->latin1list.strings = NULL;
+    }
     break;
 
   case ID3_FIELD_TYPE_STRING:
   case ID3_FIELD_TYPE_STRINGFULL:
-    if (field->string.ptr)
+    if (field->string.ptr) {
       free(field->string.ptr);
+      field->string.ptr = NULL;
+    }
     break;
 
   case ID3_FIELD_TYPE_STRINGLIST:
-    for (i = 0; i < field->stringlist.nstrings; ++i)
-      free(field->stringlist.strings[i]);
+    if (field->stringlist.strings) {
+      for (i = 0; i < field->stringlist.nstrings; ++i)
+        free(field->stringlist.strings[i]);
 
-    if (field->stringlist.strings)
       free(field->stringlist.strings);
+      field->stringlist.nstrings = 0;
+      field->stringlist.strings = NULL;
+    }
     break;
 
   case ID3_FIELD_TYPE_INT32PLUS:
   case ID3_FIELD_TYPE_BINARYDATA:
-    if (field->binary.data)
-      free(field->binary.data);
+    if (field->binary.data) {
+       free(field->binary.data);
+       field->binary.data = NULL;
+    }
     break;
   }