From: Ivan Maidanski Date: Fri, 8 Jun 2012 17:10:17 +0000 (+0400) Subject: Fix CORD_cat_char_star to prevent SEGV in case of out-of-memory X-Git-Tag: gc7_2c~1^2~1 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5591275f04b1b94395e38eeada745cd97bc8b613;p=gc Fix CORD_cat_char_star to prevent SEGV in case of out-of-memory * cordbscs.c (CORD_cat_char_star): Check GC_MALLOC_ATOMIC result for NULL (do OUT_OF_MEMORY in such case) to prevent SEGV. --- diff --git a/cord/cordbscs.c b/cord/cordbscs.c index 924bf445..5128daf5 100644 --- a/cord/cordbscs.c +++ b/cord/cordbscs.c @@ -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';