summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/package.cc
diff options
context:
space:
mode:
authorAdam Borowski <kilobyte@angband.pl>2010-09-12 16:28:29 +0200
committerAdam Borowski <kilobyte@angband.pl>2010-09-13 11:02:57 +0200
commita9c49d071909d915e50c5d78deaa8dfe59009834 (patch)
tree61b753acbe8d14deb1ea1b34cdd3840159d38698 /crawl-ref/source/package.cc
parent0dbbb82c9d2d6a4bf0b8b39182ce38310bcde741 (diff)
downloadcrawl-ref-a9c49d071909d915e50c5d78deaa8dfe59009834.tar.gz
crawl-ref-a9c49d071909d915e50c5d78deaa8dfe59009834.zip
Give a nicer message for an empty save -- it's not really corrupted.
Diffstat (limited to 'crawl-ref/source/package.cc')
-rw-r--r--crawl-ref/source/package.cc5
1 files changed, 5 insertions, 0 deletions
diff --git a/crawl-ref/source/package.cc b/crawl-ref/source/package.cc
index 56f5686e0b..37f0a53f6d 100644
--- a/crawl-ref/source/package.cc
+++ b/crawl-ref/source/package.cc
@@ -120,6 +120,11 @@ package::package(const char* file, bool writeable, bool empty)
ssize_t res = ::read(fd, &head, sizeof(file_header));
if (res < 0)
sysfail("error reading the save file (%s)", file);
+ if (!res || !(head.magic || head.version || head.padding[0]
+ || head.padding[1] || head.padding[2] || head.start))
+ {
+ fail("The save file (%s) is empty!", file);
+ }
if (res != sizeof(file_header))
fail("save file (%s) corrupted -- header truncated", file);