handle undefined ID exception
authorkramm <kramm>
Mon, 29 Mar 2004 18:38:43 +0000 (18:38 +0000)
committerkramm <kramm>
Mon, 29 Mar 2004 18:38:43 +0000 (18:38 +0000)
lib/python/SWF.c
lib/python/tag.c
lib/python/taglist.c

index b191927..d8ff006 100644 (file)
@@ -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);
        }
index 22cc8f0..23cf8f9 100644 (file)
@@ -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)
index 711817e..630fb29 100644 (file)
@@ -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);