commit f057ea6ebc1f7daa848e82b24de1f3f181d19cc0
parent 24f7db2f674741749c89fb666708c53e1cbe54d4
Author: sin <sin@2f30.org>
Date: Tue, 23 Sep 2014 10:56:00 +0100
Scream if the datafile has 0 length
Diffstat:
1 file changed, 6 insertions(+), 0 deletions(-)
diff --git a/ratox.c b/ratox.c
@@ -588,6 +588,12 @@ dataload(void)
sz = lseek(fd, 0, SEEK_END);
lseek(fd, 0, SEEK_SET);
+ if (sz == 0) {
+ fprintf(stderr, "%s seems to be corrupt\n",
+ DATAFILE);
+ exit(EXIT_FAILURE);
+ }
+
data = malloc(sz);
if (!data) {
perror("malloc");