taglist no longer contain an END tag
[swftools.git] / lib / python / SWF.c
index e011841..d8ff006 100644 (file)
@@ -103,6 +103,8 @@ static PyObject* f_load(PyObject* self, PyObject* args)
        return NULL;
 
     swf = PyObject_New(SWFObject, &SWFClass);
+    mylog("+%08x(%d) f_load\n", (int)swf, swf->ob_refcnt);
+
     memset(&swf->swf, 0, sizeof(SWF));
     swf->filename = strdup(filename);
 
@@ -121,11 +123,13 @@ static PyObject* f_load(PyObject* self, PyObject* args)
        return 0;
     }
     close(fi);
-    swf->swf.firstTag = 0;
 
     swf->taglist = taglist_new2(swf->swf.firstTag);
+    if(swf->taglist == NULL) {
+       return NULL;
+    }
+    swf->swf.firstTag = 0;
     
-    mylog("+%08x(%d) load\n", (int)self, self->ob_refcnt);
     return (PyObject*)swf;
 }
 //----------------------------------------------------------------------------
@@ -148,6 +152,8 @@ static PyObject * swf_save(PyObject* self, PyObject* args, PyObject* kwargs)
 
     if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|si", kwlist, &filename, &compress))
        return NULL;
+    
+    mylog(" %08x(%d) f_save filename=%s compress=%d\n", (int)self, self->ob_refcnt, filename, compress);
 
     // keyword arg compress (=1) forces compression
     if(compress)
@@ -160,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);
        }