From 004e6e47f1d96bd1271306f98b9e21d273262a7b Mon Sep 17 00:00:00 2001 From: Ivan Maidanski Date: Tue, 16 Feb 2016 00:32:01 +0300 Subject: [PATCH] Fix null-pointer dereferences on out-of-memory in cord/de * cord/tests/de.c (add_map, add_hist): Check GC_NEW() result for null. --- cord/tests/de.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cord/tests/de.c b/cord/tests/de.c index c42de8e..da2305e 100644 --- a/cord/tests/de.c +++ b/cord/tests/de.c @@ -141,6 +141,7 @@ void add_map(int line, size_t pos) { line_map new_map = GC_NEW(struct LineMapRep); + if (NULL == new_map) OUT_OF_MEMORY; if (current_map_size >= MAX_MAP_SIZE) prune_map(); new_map -> line = line; new_map -> pos = pos; @@ -186,6 +187,7 @@ void add_hist(CORD s) { history new_file = GC_NEW(struct HistoryRep); + if (NULL == new_file) OUT_OF_MEMORY; new_file -> file_contents = current = s; current_len = CORD_len(s); new_file -> previous = now; -- 2.7.4