From 2206626c3b7fa0997a2472a28b78f3d42bfd2ae7 Mon Sep 17 00:00:00 2001 From: kramm Date: Thu, 8 Apr 2004 09:23:30 +0000 Subject: [PATCH] fixed another malloc(0) --- lib/python/tag.c | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) 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;idata[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;idata[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; } -- 1.7.10.4