From 62a3ac93d936ea0cd0a12aaa8f376d82e9fe3a79 Mon Sep 17 00:00:00 2001 From: Ruben Ayrapetyan Date: Fri, 13 Feb 2015 16:38:59 +0300 Subject: [PATCH] Fix invocation of memcpy in add_current_token_to_string_cache (NULL pointer shouldn't be passed to memcpy). --- src/parser/js/lexer.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/parser/js/lexer.cpp b/src/parser/js/lexer.cpp index 814fa672a..30cdccbd9 100644 --- a/src/parser/js/lexer.cpp +++ b/src/parser/js/lexer.cpp @@ -175,10 +175,10 @@ add_current_token_to_string_cache (void) + ((size_t) length + 1) * sizeof (ecma_char_t)); ecma_char_t *temp = (ecma_char_t *) mem_heap_alloc_block (strings_cache_size, MEM_HEAP_ALLOC_SHORT_TERM); - memcpy (temp, strings_cache, strings_cache_used_size); - STACK_ITERATE_VARG_SET (literals, adjust_string_ptrs, 0, (size_t) (temp - strings_cache)); if (strings_cache) { + memcpy (temp, strings_cache, strings_cache_used_size); + STACK_ITERATE_VARG_SET (literals, adjust_string_ptrs, 0, (size_t) (temp - strings_cache)); mem_heap_free_block ((uint8_t *) strings_cache); } strings_cache = temp;