]> 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>
Fri, 2 May 2014 20:34:21 +0000 (00:34 +0400)
* headers.c (GC_scratch_alloc): Do not update GC_scratch_last_end_ptr
if allocation failed ("result" variable is NULL).

headers.c

index 4e2c2d09d9503bf558a8de5c9d7eeaa23660b7c2..87f197828d94595cab275acb06a34a6532443128 100644 (file)
--- a/headers.c
+++ b/headers.c
@@ -134,7 +134,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);
         }