From 65b85c15e78df0be1d5e4d5aba2e45ce57d88e15 Mon Sep 17 00:00:00 2001
From: kramm <kramm>
Date: Thu, 30 May 2002 17:59:08 +0000
Subject: [PATCH] Fix: don't modify fileSize and frameCount in header when
 writing it with swf_WriteHeader().

---
 lib/rfxswf.c |   11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/lib/rfxswf.c b/lib/rfxswf.c
index f188d79..77e34d7 100644
--- a/lib/rfxswf.c
+++ b/lib/rfxswf.c
@@ -851,6 +851,7 @@ int swf_ReadSWF(int handle, SWF * swf)
 int  swf_WriteSWF2(struct writer_t*writer, SWF * swf, bool compress)     // Writes SWF to file, returns length or <0 if fails
 { U32 len;
   TAG * t;
+  int frameCount=0;
   struct writer_t zwriter;
     
   if (!swf) return -1;
@@ -869,11 +870,11 @@ int  swf_WriteSWF2(struct writer_t*writer, SWF * swf, bool compress)     // Writ
 
   len = 0;
   t = swf->firstTag;
-  swf->frameCount = 0;
+  frameCount = 0;
 
   while(t)
   { len += swf_WriteTag(-1, t);
-    if (t->id==ST_SHOWFRAME) swf->frameCount++;
+    if (t->id==ST_SHOWFRAME) frameCount++;
     t = swf_NextTag(t);
   }
   
@@ -896,7 +897,11 @@ int  swf_WriteSWF2(struct writer_t*writer, SWF * swf, bool compress)     // Writ
       swf_SetU16(&t2, swf->frameCount);
       l = swf_GetTagLen(&t2)+8;
     }
-    swf->fileSize = l+len;
+
+    if(len) {// don't touch headers without tags
+	swf->fileSize = l+len;
+	swf->frameCount = frameCount;
+    }
    
     if(compress) {
       char*id = "CWS";
-- 
1.7.10.4