From: kramm <kramm>
Date: Thu, 8 Apr 2004 09:23:30 +0000 (+0000)
Subject: fixed another malloc(0)
X-Git-Tag: stable_core_1
X-Git-Url: http://git.asbjorn.biz/?a=commitdiff_plain;h=2206626c3b7fa0997a2472a28b78f3d42bfd2ae7;p=swftools.git

fixed another malloc(0)
---

diff --git a/lib/python/tag.c b/lib/python/tag.c
index 5bc539f..65e19b3 100644
--- a/lib/python/tag.c
+++ b/lib/python/tag.c
@@ -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;
 }