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.
This commit is contained in:
Mark Liversedge
2013-02-20 20:20:32 +00:00
parent 4c244327c6
commit 714c635f55

View File

@@ -50,8 +50,11 @@ static double JsonNumber;
static QStringList JsonRideFileerrors;
static QMap <QString, QString> 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<RideFile*>*
// release the file handle
fclose(JsonRideFilein);
// clean up
JsonRideFilelex_destroy();
// Only get errors so fail if we have any
if (errors.count()) {
errors << JsonRideFileerrors;