X-Git-Url: http://git.asbjorn.biz/?p=swftools.git;a=blobdiff_plain;f=lib%2Frfxswf.c;h=bd8cd17ac2efee628f3859a5d795494f48b8bdfb;hp=b063cc07f60c4e1c04cfbb5ae4c599bb2144e5c2;hb=f5626be739a1e1b61f89d7a389be3c4b5d4d9128;hpb=0185c09ff339aaf744142f96d22e1b145334539d diff --git a/lib/rfxswf.c b/lib/rfxswf.c index b063cc0..bd8cd17 100644 --- a/lib/rfxswf.c +++ b/lib/rfxswf.c @@ -1470,6 +1470,7 @@ int swf_ReadSWF2(reader_t*reader, SWF * swf) // Reads SWF to memory (malloc'ed swf->frameCount = SWAP16(swf->frameCount); /* read tags and connect to list */ + t1.next = 0; t = &t1; while (t) { t = swf_ReadTag(reader,t); @@ -1479,7 +1480,8 @@ int swf_ReadSWF2(reader_t*reader, SWF * swf) // Reads SWF to memory (malloc'ed } } swf->firstTag = t1.next; - t1.next->prev = NULL; + if(t1.next) + t1.next->prev = NULL; } return reader->pos; @@ -1709,6 +1711,21 @@ int swf_WriteSWF2(writer_t*writer, SWF * swf) // Writes SWF to file, return } } +int swf_SaveSWF(SWF * swf, char*filename) +{ + int fi = open(filename, O_BINARY|O_RDWR|O_TRUNC|O_CREAT, 0777); + if(fi<0) { + perror(filename); + return 0; + } + if(swf_WriteSWF(fi, swf)<0) { + fprintf(stderr, "Unable to write output file: %s\n", filename); + return 0; + } + close(fi); + return 1; +} + int swf_WriteSWF(int handle, SWF * swf) // Writes SWF to file, returns length or <0 if fails { writer_t writer;