1
0
Fork 0
mirror of https://github.com/davatorium/rofi.git synced 2024-11-18 13:54:36 -05:00

Fix memory leak on parser fail.

This commit is contained in:
Dave Davenport 2017-04-06 09:12:03 +02:00
parent 387093a673
commit 898b5466f0
2 changed files with 17 additions and 0 deletions

View file

@ -573,6 +573,14 @@ gboolean rofi_theme_parse_file ( const char *file )
yylex_destroy ();
yyin = NULL;
while ( (po = g_queue_pop_head ( file_queue ) )) {
if ( po ) {
if ( po->type == PT_FILE ){
fclose ( po->filein );
}
g_free ( po );
}
}
// Free up.
g_list_foreach ( imported_files, (GFunc)g_free, NULL);
g_list_free ( imported_files );
@ -601,6 +609,14 @@ gboolean rofi_theme_parse_string ( const char *string )
int parser_retv = yyparse ( string );
yylex_destroy ();
while ( (po = g_queue_pop_head ( file_queue ) )) {
if ( po ) {
if ( po->type == PT_FILE ){
fclose ( po->filein );
}
g_free ( po );
}
}
// Free up.
g_list_foreach ( imported_files, (GFunc)g_free, NULL);
g_list_free ( imported_files );

View file

@ -86,6 +86,7 @@ int main ( int argc, char ** argv )
TASSERT ( rofi_theme != NULL );
rofi_theme_free ( rofi_theme );
rofi_theme = NULL;
rofi_theme_parse_string ( " Blaat ");
TASSERT ( rofi_theme != NULL );
TASSERT ( error == TRUE );