[AD] dat2c bugfixes

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


Some issues with dat2c.c:
1. Didn't free memory allocated by cvt_FONT_color
2. Allocating 4 bytes (rather than 5) to allocate "data"
3. Overflow because of allocating not enough memory.

This bug was found with DJGPP 2.3 (GCC 2.952), Allegro WIP 4.1.2. The
following patch fixes them all.


--- tools/dat2c.old	Wed Aug 28 20:01:50 2002
+++ tools/dat2c.new	Wed Aug 28 20:53:06 2002
@@ -1279,6 +1279,7 @@
         data_count++;
     }
     
+    free(name_buf);
     return data_count;
 }
 
@@ -1627,7 +1628,8 @@
     char* prefixed_name = 0;
     
     prefixed_name = malloc(5 +
-        (dat2c->prefix ? (signed)strlen(dat2c->prefix) : -1));
+        (dat2c->prefix ? (signed)strlen(dat2c->prefix) : 0) +
+        (dat2c->datafile_name ? (signed)strlen(dat2c->datafile_name) : 0));
     if(!prefixed_name) out_of_memory();
     sprintf(prefixed_name, "%s%s%s", 
         dat2c->prefix ? dat2c->prefix : "",


--
Roberto Alfonso (rpgrca@xxxxxxxxxx <> rpgrca@xxxxxxxxxx)
Rhynox, the Noble Rockfriend, Wild Battlerager of the Neidar Clan and
Proficient Blacksmith, rising hero, male dwarf (Genesis is the key)
ICQ: 44361979



Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/