From d6752417337b70cde2264cc384304740de9908f6 Mon Sep 17 00:00:00 2001 From: Ivan Maidanski Date: Fri, 8 Jun 2012 21:10:17 +0400 Subject: [PATCH] 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. --- cord/cordbscs.c | 1 + 1 file changed, 1 insertion(+) diff --git a/cord/cordbscs.c b/cord/cordbscs.c index 0314b7ae..d240fa36 100644 --- a/cord/cordbscs.c +++ b/cord/cordbscs.c @@ -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'; -- 2.40.0