From: William D. <wdo...@us...> - 2005-02-23 18:05:04
|
Update of /cvsroot/flexml/flexml In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6495 Modified Files: skel Log Message: Fix memory leak reported in bug #1126171; thanks to Ulrik Petersen for patch. Index: skel =================================================================== RCS file: /cvsroot/flexml/flexml/skel,v retrieving revision 1.24 retrieving revision 1.25 diff -u -d -r1.24 -r1.25 --- skel 10 Feb 2005 11:42:39 -0000 1.24 +++ skel 23 Feb 2005 18:04:38 -0000 1.25 @@ -55,12 +55,16 @@ /* Generic actions. */ #define SKIP /*skip*/ -#define SUCCEED return 0 +#define SUCCEED CLEANUP; return 0 #define FAIL return fail static int fail(const char*, ...); const char * parse_err_msg(void); +/* Cleanup */ +static void cleanup(void); +#define CLEANUP cleanup() + /* Text buffer stack handling. */ char bufferstack[FLEXML_BUFFERSTACKSIZE]; char* limit = bufferstack + FLEXML_BUFFERSTACKSIZE; @@ -213,7 +217,7 @@ /* EPILOG: after the root element. */ <EPILOG>{ - . {SET(PROLOG); yyless(0); return -1;} + . {SET(PROLOG); yyless(0); CLEANUP; return -1;} <<EOF>> SUCCEED; } @@ -319,6 +323,13 @@ } +static void cleanup(void) +{ + if (statenames) + free(statenames); +} + + static int fail(const char* fmt, ...) { int chars_left, used; @@ -341,6 +352,8 @@ fprintf(stderr, "%s\n", flexml_err_msg); flexml_err_msg[0] = '\0'; #endif - + + cleanup(); + return 1; } |