fixed another malloc(0) stable_core_1
authorkramm <kramm>
Thu, 8 Apr 2004 09:23:30 +0000 (09:23 +0000)
committerkramm <kramm>
Thu, 8 Apr 2004 09:23:30 +0000 (09:23 +0000)
lib/python/tag.c

index 5bc539f..65e19b3 100644 (file)
@@ -362,21 +362,23 @@ TAG* tag_getTAG(PyObject*self, TAG*prevTag, PyObject*tagmap)
     }
 
     int num = swf_GetNumUsedIDs(t);
-    int * positions = malloc(num*sizeof(int));
-    swf_GetUsedIDs(t, positions);
-    int i;
-    for(i=0;i<num;i++) {
-       int id = GET16(&t->data[positions[i]]);
-       PyObject* obj =  tagmap_id2obj(tag->tagmap, id);
-       if(obj==NULL) {
-           PyErr_SetString(PyExc_Exception, setError("Internal error: id %d not known in taglist:"));
-           free(positions);
-           return 0;
+    if(num) { // tag has dependencies
+       int * positions = malloc(num*sizeof(int));
+       swf_GetUsedIDs(t, positions);
+       int i;
+       for(i=0;i<num;i++) {
+           int id = GET16(&t->data[positions[i]]);
+           PyObject* obj =  tagmap_id2obj(tag->tagmap, id);
+           if(obj==NULL) {
+               PyErr_SetString(PyExc_Exception, setError("Internal error: id %d not known in taglist:"));
+               free(positions);
+               return 0;
+           }
+           int newid = tagmap_obj2id(tagmap, obj);
+           PUT16(&t->data[positions[i]], newid);
        }
-       int newid = tagmap_obj2id(tagmap, obj);
-       PUT16(&t->data[positions[i]], newid);
+       free(positions);
     }
-    free(positions);
     return t;
 }