X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=lib%2Fpython%2FSWF.c;h=fd7c4231c33f7df8b78fc6af1d52634c2b0f5150;hb=84245258e84d865fb1b5a0a6a781c099946398df;hp=d8ff0062878e898eb040d757dd1691284835dae5;hpb=d2195f33bb9e52ad053c08583094394463f58fb6;p=swftools.git diff --git a/lib/python/SWF.c b/lib/python/SWF.c index d8ff006..fd7c423 100644 --- a/lib/python/SWF.c +++ b/lib/python/SWF.c @@ -128,6 +128,8 @@ static PyObject* f_load(PyObject* self, PyObject* args) if(swf->taglist == NULL) { return NULL; } + + swf_FreeTags(&swf->swf); swf->swf.firstTag = 0; return (PyObject*)swf; @@ -160,6 +162,8 @@ static PyObject * swf_save(PyObject* self, PyObject* args, PyObject* kwargs) swf->compressed = 1; swf->firstTag = taglist_getTAGs(swfo->taglist); + if(!swf->firstTag) + return NULL; // fix the file, in case it is empty or not terminated properly { @@ -167,7 +171,6 @@ static PyObject * swf_save(PyObject* self, PyObject* args, PyObject* kwargs) if(!tag) tag = swf->firstTag = swf_InsertTag(0,ST_END); while(tag && tag->next) { - mylog(" tag:%08x\n", tag); tag = tag->next; } if(tag->id != ST_END) { @@ -194,8 +197,10 @@ static PyObject * swf_save(PyObject* self, PyObject* args, PyObject* kwargs) } } close(fi); - - swf->firstTag = 0; + + /* TODO: why is this segfaulting?? */ + /* swf_FreeTags(swf); + swf->firstTag = 0;*/ return PY_NONE; } @@ -206,6 +211,8 @@ static PyObject * swf_writeCGI(PyObject* self, PyObject* args) if(!self || !PyArg_ParseTuple(args,"")) return NULL; swf->swf.firstTag = taglist_getTAGs(swf->taglist); + if(!swf->swf.firstTag) + return NULL; swf_WriteCGI(&swf->swf); swf->swf.firstTag = 0; return PY_NONE;