]> 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:10:17 +0000 (21:10 +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 0314b7aebb22fd5b7299d37e1cf2cdb4b0fa6299..d240fa36288f74fae34cd48e642c3da33a475e62 100644 (file)
@@ -193,6 +193,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';