From: kramm <kramm>
Date: Mon, 29 Mar 2004 18:38:43 +0000 (+0000)
Subject: handle undefined ID exception
X-Git-Tag: stable_core_1~32
X-Git-Url: http://git.asbjorn.biz/?a=commitdiff_plain;h=c5a01b369d8e9318a980defffe7d805b682f66b3;p=swftools.git

handle undefined ID exception
---

diff --git a/lib/python/SWF.c b/lib/python/SWF.c
index b191927..d8ff006 100644
--- a/lib/python/SWF.c
+++ b/lib/python/SWF.c
@@ -125,6 +125,9 @@ static PyObject* f_load(PyObject* self, PyObject* args)
     close(fi);
 
     swf->taglist = taglist_new2(swf->swf.firstTag);
+    if(swf->taglist == NULL) {
+	return NULL;
+    }
     swf->swf.firstTag = 0;
     
     return (PyObject*)swf;
@@ -163,8 +166,10 @@ static PyObject * swf_save(PyObject* self, PyObject* args, PyObject* kwargs)
 	TAG*tag = swf->firstTag;
 	if(!tag)
 	    tag = swf->firstTag = swf_InsertTag(0,ST_END);
-	while(tag && tag->next)
+	while(tag && tag->next) {
+	    mylog(" tag:%08x\n", tag);
 	    tag = tag->next;
+	}
 	if(tag->id != ST_END) {
 	    tag = swf_InsertTag(tag,ST_END);
 	}
diff --git a/lib/python/tag.c b/lib/python/tag.c
index 22cc8f0..23cf8f9 100644
--- a/lib/python/tag.c
+++ b/lib/python/tag.c
@@ -139,7 +139,7 @@ PyObject* tag_new()
 PyObject* tag_new2(TAG*t, PyObject* tagmap)
 {
     TagObject*tag = PyObject_New(TagObject, &TagClass);
-    mylog("+%08x(%d) tag_new\n", (int)tag, tag->ob_refcnt);
+    mylog("+%08x(%d) tag_new tag=%08x\n", (int)tag, tag->ob_refcnt, t);
     tag->font = 0;
     tag->character = 0;
     tag->placeobject = 0;
@@ -334,9 +334,9 @@ TAG* tag_getRAWTAG(PyObject*self)
 /* serialize */
 TAG* tag_getTAG(PyObject*self, TAG*prevTag, PyObject*tagmap)
 {
-    mylog(" %08x(%d) tag_getTAG tagmap=%08x \n", (int)self, self->ob_refcnt, tagmap);
     TagObject*tag = (TagObject*)self;
     TAG* t = tag_getRAWTAG(self);
+    mylog(" %08x(%d) tag_getTAG tagmap=%08x tag=%08x\n", (int)self, self->ob_refcnt, tagmap, t);
     t->next = 0;
     t->prev = prevTag;
     if(prevTag)
diff --git a/lib/python/taglist.c b/lib/python/taglist.c
index 711817e..630fb29 100644
--- a/lib/python/taglist.c
+++ b/lib/python/taglist.c
@@ -42,6 +42,10 @@ PyObject * taglist_new2(TAG*tag)
     t = tag;
     while(t) {
 	PyObject*newtag = tag_new2(t, taglist->tagmap);
+	if(newtag==NULL) {
+	    // pass through exception
+	    return NULL;
+	}
 	PyList_SET_ITEM(taglist->taglist,nr,newtag);Py_INCREF(newtag);
 	if(swf_isDefiningTag(t)) {
 	    tagmap_add(taglist->tagmap, newtag);