From 714c635f55df9ea58ba80d7a67a5df6e5a0ba55e Mon Sep 17 00:00:00 2001 From: Mark Liversedge Date: Wed, 20 Feb 2013 20:20:32 +0000 Subject: [PATCH] Code Cleanup: Json lexer memory leak .. possibly. According to the docs we need to free the malloc'ed memory in the lexer when parsing completes. --- src/JsonRideFile.y | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/JsonRideFile.y b/src/JsonRideFile.y index bdd1e4f75..18fda452a 100644 --- a/src/JsonRideFile.y +++ b/src/JsonRideFile.y @@ -50,8 +50,11 @@ static double JsonNumber; static QStringList JsonRideFileerrors; static QMap JsonOverrides; -// Standard yacc/lex variables / functions +// Lex scanner extern int JsonRideFilelex(); // the lexer aka yylex() +extern int JsonRideFilelex_destroy(void); // the cleaner for lexer + +// yacc parser extern void JsonRideFilerestart (FILE *input_file); // the lexer file restart aka yyrestart() extern FILE *JsonRideFilein; // used by the lexer aka yyin extern char *JsonRideFiletext; // set by the lexer aka yytext @@ -264,6 +267,9 @@ JsonFileReader::openRideFile(QFile &file, QStringList &errors, QList* // release the file handle fclose(JsonRideFilein); + // clean up + JsonRideFilelex_destroy(); + // Only get errors so fail if we have any if (errors.count()) { errors << JsonRideFileerrors;