Blob Blame Raw
From 3114d144110530dc86dd82ebe2e72d89eda1855f Mon Sep 17 00:00:00 2001
From: Dave Love <dave.love@manchester.ac.uk>
Date: Wed, 17 May 2017 00:10:15 +0100
Subject: [PATCH] Zero memory written to image

---
 src/lib/image-util.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/lib/image-util.c b/src/lib/image-util.c
index 687d6860..b1c5dfef 100644
--- a/src/lib/image-util.c
+++ b/src/lib/image-util.c
@@ -102,9 +102,13 @@ int singularity_image_offset(FILE *image_fp) {
 
 int singularity_image_create(char *image, int size) {
     FILE *image_fp;
-    char *buff = (char *) xmalloc(1024*1024);
+    char *buff = calloc(1024*1024, 1);
     int i;
 
+    if (!buff) {
+        fprintf(stderr, "ABORT: Can't allocate memory\n");
+        abort();
+    }
     singularity_message(VERBOSE, "Creating new sparse image at: %s\n", image);
 
     if ( is_file(image) == 0 ) {
-- 
2.11.0