@@ -3159,19 +3159,23 @@ scanner_scan_all (parser_context_t *context_p, /**< context */
31593159 }
31603160 PARSER_CATCH
31613161 {
3162- /* Ignore the errors thrown by the lexer. */
3163- if (context_p -> error != PARSER_ERR_OUT_OF_MEMORY )
3164- {
3165- context_p -> error = PARSER_ERR_NO_ERROR ;
3166- }
3167-
31683162#if ENABLED (JERRY_ES2015 )
31693163 while (scanner_context .active_binding_list_p != NULL )
31703164 {
31713165 scanner_pop_binding_list (& scanner_context );
31723166 }
31733167#endif /* ENABLED (JERRY_ES2015) */
31743168
3169+ if (JERRY_UNLIKELY (context_p -> error == PARSER_ERR_OUT_OF_MEMORY ))
3170+ {
3171+ scanner_release_active_literal_pool (& scanner_context );
3172+ parser_stack_free (context_p );
3173+ return ;
3174+ }
3175+
3176+ /* Ignore the errors thrown by the lexer. */
3177+ context_p -> error = PARSER_ERR_NO_ERROR ;
3178+
31753179 /* The following code may allocate memory, so it is enclosed in a try/catch. */
31763180 PARSER_TRY (context_p -> try_buffer )
31773181 {
@@ -3193,17 +3197,16 @@ scanner_scan_all (parser_context_t *context_p, /**< context */
31933197 }
31943198 PARSER_CATCH
31953199 {
3196- JERRY_ASSERT (context_p -> error == PARSER_ERR_NO_ERROR );
3200+ JERRY_ASSERT (context_p -> error == PARSER_ERR_NO_ERROR || context_p -> error == PARSER_ERR_OUT_OF_MEMORY );
31973201
3198- while (scanner_context .active_literal_pool_p != NULL )
3199- {
3200- scanner_literal_pool_t * literal_pool_p = scanner_context .active_literal_pool_p ;
3202+ scanner_release_active_literal_pool (& scanner_context );
32013203
3202- scanner_context . active_literal_pool_p = literal_pool_p -> prev_p ;
3203-
3204- parser_list_free ( & literal_pool_p -> literal_pool );
3205- scanner_free ( literal_pool_p , sizeof ( scanner_literal_pool_t )) ;
3204+ if ( JERRY_UNLIKELY ( context_p -> error == PARSER_ERR_OUT_OF_MEMORY ))
3205+ {
3206+ parser_stack_free ( context_p );
3207+ return ;
32063208 }
3209+
32073210 }
32083211 PARSER_TRY_END
32093212
0 commit comments