diff --git a/samples/chart-tests.gnumeric b/samples/chart-tests.gnumeric
index ac28bbc..1043e95 100644
Binary files a/samples/chart-tests.gnumeric and b/samples/chart-tests.gnumeric differ
diff --git a/src/go-data-cache.c b/src/go-data-cache.c
index 2b7f6d1..39000d2 100644
--- a/src/go-data-cache.c
+++ b/src/go-data-cache.c
@@ -51,7 +51,9 @@ go_data_cache_records_set_size (GODataCache *cache, unsigned int n)
 	if (0 == expand)
 		return;
 
-	cache->records = g_realloc (cache->records, n * cache->record_size);
+	cache->records = g_try_realloc (cache->records, n * cache->record_size);
+	if (cache->records == NULL)
+		return;
 	if (expand > 0)
 		memset (cache->records + cache->records_allocated * cache->record_size, 0,
 			expand * cache->record_size);
