@@ -3159,19 +3159,23 @@ scanner_scan_all (parser_context_t *context_p, /**< context */
3159
3159
}
3160
3160
PARSER_CATCH
3161
3161
{
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
-
3168
3162
#if ENABLED (JERRY_ES2015 )
3169
3163
while (scanner_context .active_binding_list_p != NULL )
3170
3164
{
3171
3165
scanner_pop_binding_list (& scanner_context );
3172
3166
}
3173
3167
#endif /* ENABLED (JERRY_ES2015) */
3174
3168
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
+
3175
3179
/* The following code may allocate memory, so it is enclosed in a try/catch. */
3176
3180
PARSER_TRY (context_p -> try_buffer )
3177
3181
{
@@ -3193,17 +3197,16 @@ scanner_scan_all (parser_context_t *context_p, /**< context */
3193
3197
}
3194
3198
PARSER_CATCH
3195
3199
{
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 );
3197
3201
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 );
3201
3203
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 ;
3206
3208
}
3209
+
3207
3210
}
3208
3211
PARSER_TRY_END
3209
3212
0 commit comments