summaryrefslogtreecommitdiff
path: root/cord/cordbscs.c
diff options
context:
space:
mode:
authorIvan Maidanski <ivmai@mail.ru>2012-06-08 19:10:17 +0200
committerIvan Maidanski <ivmai@mail.ru>2012-06-08 19:20:02 +0200
commit5591275f04b1b94395e38eeada745cd97bc8b613 (patch)
treec5929f48198b77eeda7314e38200f62c73c12e38 /cord/cordbscs.c
parent0a1643fa4cf7cbc31d87a04ae14fd94eefde4a28 (diff)
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.
Diffstat (limited to 'cord/cordbscs.c')
-rw-r--r--cord/cordbscs.c1
1 files changed, 1 insertions, 0 deletions
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';