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:
parent
387093a673
commit
898b5466f0
2 changed files with 17 additions and 0 deletions
|
@ -573,6 +573,14 @@ gboolean rofi_theme_parse_file ( const char *file )
|
||||||
yylex_destroy ();
|
yylex_destroy ();
|
||||||
yyin = NULL;
|
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.
|
// Free up.
|
||||||
g_list_foreach ( imported_files, (GFunc)g_free, NULL);
|
g_list_foreach ( imported_files, (GFunc)g_free, NULL);
|
||||||
g_list_free ( imported_files );
|
g_list_free ( imported_files );
|
||||||
|
@ -601,6 +609,14 @@ gboolean rofi_theme_parse_string ( const char *string )
|
||||||
int parser_retv = yyparse ( string );
|
int parser_retv = yyparse ( string );
|
||||||
yylex_destroy ();
|
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.
|
// Free up.
|
||||||
g_list_foreach ( imported_files, (GFunc)g_free, NULL);
|
g_list_foreach ( imported_files, (GFunc)g_free, NULL);
|
||||||
g_list_free ( imported_files );
|
g_list_free ( imported_files );
|
||||||
|
|
|
@ -86,6 +86,7 @@ int main ( int argc, char ** argv )
|
||||||
TASSERT ( rofi_theme != NULL );
|
TASSERT ( rofi_theme != NULL );
|
||||||
rofi_theme_free ( rofi_theme );
|
rofi_theme_free ( rofi_theme );
|
||||||
rofi_theme = NULL;
|
rofi_theme = NULL;
|
||||||
|
|
||||||
rofi_theme_parse_string ( " Blaat ");
|
rofi_theme_parse_string ( " Blaat ");
|
||||||
TASSERT ( rofi_theme != NULL );
|
TASSERT ( rofi_theme != NULL );
|
||||||
TASSERT ( error == TRUE );
|
TASSERT ( error == TRUE );
|
||||||
|
|
Loading…
Reference in a new issue