From 5591275f04b1b94395e38eeada745cd97bc8b613 Mon Sep 17 00:00:00 2001 From: Ivan Maidanski Date: Fri, 8 Jun 2012 21:10:17 +0400 Subject: [PATCH 8/9] 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 924bf44..5128daf 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'; -- 1.7.10.2