aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libcrystfel/src/detector.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/libcrystfel/src/detector.c b/libcrystfel/src/detector.c
index bd0c94f1..fd04beaf 100644
--- a/libcrystfel/src/detector.c
+++ b/libcrystfel/src/detector.c
@@ -1718,7 +1718,7 @@ char *load_entire_file(const char *filename)
return NULL;
}
- contents = malloc(statbuf.st_size);
+ contents = malloc(statbuf.st_size+1);
if ( contents == NULL ) {
ERROR("Failed to allocate memory for file\n");
return NULL;
@@ -1736,6 +1736,7 @@ char *load_entire_file(const char *filename)
free(contents);
return NULL;
}
+ contents[statbuf.st_size] = '\0';
fclose(fh);