]> granicus.if.org Git - gc/commitdiff
Fix CORD_cat_char_star to prevent SEGV in case of out-of-memory
authorIvan Maidanski <ivmai@mail.ru>
Fri, 8 Jun 2012 17:10:17 +0000 (21:10 +0400)
committerIvan Maidanski <ivmai@mail.ru>
Fri, 8 Jun 2012 17:20:02 +0000 (21:20 +0400)
* cordbscs.c (CORD_cat_char_star): Check GC_MALLOC_ATOMIC result for
NULL (do OUT_OF_MEMORY in such case) to prevent SEGV.

cord/cordbscs.c

index 924bf44549e1198055751627c055c180b0b19395..5128daf5ded5a81e377d1783b95e82c6b924ac41 100644 (file)
@@ -188,6 +188,7 @@ CORD CORD_cat_char_star(CORD x, const char * y, size_t leny)
             result_len = right_len + leny;  /* length of new_right */
             if (result_len <= SHORT_LIMIT) {
                 new_right = GC_MALLOC_ATOMIC(result_len + 1);
+                if (new_right == 0) OUT_OF_MEMORY;
                 memcpy(new_right, right, right_len);
                 memcpy(new_right + right_len, y, leny);
                 new_right[result_len] = '\0';