From: Peter Verthez Date: Sat, 21 Dec 2002 16:53:17 +0000 (+0000) Subject: Fixed memory leak. X-Git-Url: https://git.dlugolecki.net.pl/?a=commitdiff_plain;h=8b3be694cbcd352826173ac6927c94fb43ee3db4;p=gedcom-parse.git Fixed memory leak. --- diff --git a/gedcom/gedcom_date.lex b/gedcom/gedcom_date.lex index bba60ef..2350aca 100644 --- a/gedcom/gedcom_date.lex +++ b/gedcom/gedcom_date.lex @@ -149,6 +149,7 @@ int get_date_token(const char* str) int get_year_tokens(const char* str, char** year1, char** year2) { int token; + int num_tokens = 0; YY_BUFFER_STATE buffer; token_nr = 0; @@ -164,22 +165,24 @@ int get_year_tokens(const char* str, char** year1, char** year2) case SLASH: { token = yylex(); switch (token) { - case NUMBER: { + case NUMBER: *year2 = buf[token_nr - 1]; - return 2; - } - default: return 0; + num_tokens = 2; break; + default: + num_tokens = 0; } break; } - case 0: return 1; - default: return 0; + case 0: num_tokens = 1; break; + default: num_tokens = 0; } break; } - case 0: return 0; - default: return 0; + case 0: num_tokens = 0; break; + default: num_tokens = 0; } + yy_delete_buffer(buffer); + return num_tokens; } int yywrap()