]> granicus.if.org Git - gc/commitdiff
Fix GC_scratch_last_end_ptr update on GC_scratch_alloc failure
authorIvan Maidanski <ivmai@mail.ru>
Sun, 30 Mar 2014 17:05:35 +0000 (21:05 +0400)
committerIvan Maidanski <ivmai@mail.ru>
Sun, 30 Mar 2014 17:05:35 +0000 (21:05 +0400)
* headers.c (GC_scratch_alloc): Do not update GC_scratch_last_end_ptr
if allocation failed ("result" variable is NULL).

headers.c

index ea83378e89db5a201b229785e1f7b9801029d45a..108adf18b7d71975868876d96727a3955f6598bc 100644 (file)
--- a/headers.c
+++ b/headers.c
@@ -133,7 +133,9 @@ GC_INNER ptr_t GC_scratch_alloc(size_t bytes)
             result = (ptr_t)GET_MEM(bytes_to_get);
             GC_add_to_our_memory(result, bytes_to_get);
             scratch_free_ptr -= bytes;
-            GC_scratch_last_end_ptr = result + bytes;
+            if (result != NULL) {
+                GC_scratch_last_end_ptr = result + bytes;
+            }
             return(result);
         }