added overflow checking to swf_SetS16().
[swftools.git] / lib / rfxswf.c
index aea9a93..061010b 100644 (file)
@@ -179,6 +179,13 @@ int swf_SetU16(TAG * t,U16 v)
   t->data[t->len++] = a[1];
   return 0;
 }
+void swf_SetS16(TAG * t,int v)
+{
+    if(v>32767 || v<-32768) {
+       fprintf(stderr, "Warning: S16 overflow: %d\n", v);
+    }
+    swf_SetU16(t, (S16)v);
+}
 
 int swf_SetU32(TAG * t,U32 v)
 { U8 a[4];
@@ -456,7 +463,7 @@ void swf_ExpandRect3(SRECT*src, SPOINT center, int radius)
        src->ymin = center.y-radius;
        src->xmax = center.x+radius;
        src->ymax = center.y+radius;
-       if((center.x|cetner.y|radius) == 0) src->xmax++; //make sure the bbox is not NULL anymore
+       if((center.x|center.y|radius) == 0) src->xmax++; //make sure the bbox is not NULL anymore
        return;
     }
     if(center.x - radius < src->xmin)
@@ -1254,7 +1261,7 @@ int  swf_WriteSWF2(struct writer_t*writer, SWF * swf)     // Writes SWF to file,
 
   while(t) {
       len += swf_WriteTag(-1,t);
-      if(t->id == ST_DEFINESPRITE) inSprite++;
+      if(t->id == ST_DEFINESPRITE && !swf_IsFolded(t)) inSprite++;
       else if(t->id == ST_END && inSprite) inSprite--;
       else if(t->id == ST_SHOWFRAME && !inSprite) frameCount++;
       t = swf_NextTag(t);