aboutsummaryrefslogtreecommitdiffstats
path: root/file.c
diff options
context:
space:
mode:
authorGravatar Miika Turkia <miika.turkia@gmail.com>2015-08-05 19:01:49 +0300
committerGravatar Dirk Hohndel <dirk@hohndel.org>2015-08-09 23:55:45 -0700
commite4353cb4a73d99a3baeff93ea638047e038f2a65 (patch)
treeff966bbc71e4e612d25b709e3696c4d0b1c4690b /file.c
parent1f4267d0938e8a7347300d7ad258cb439ceddcfc (diff)
downloadsubsurface-e4353cb4a73d99a3baeff93ea638047e038f2a65.tar.gz
Report empty file error instead of OOM
If we are trying to open an empty file, skip the attempts to parse the input and report an appropriate error message. Signed-off-by: Miika Turkia <miika.turkia@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'file.c')
-rw-r--r--file.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/file.c b/file.c
index 0b893dc3f..8522b2e38 100644
--- a/file.c
+++ b/file.c
@@ -447,13 +447,15 @@ int parse_file(const char *filename)
if (git && !git_load_dives(git, branch))
return 0;
- if (readfile(filename, &mem) < 0) {
+ if ((ret = readfile(filename, &mem)) < 0) {
/* we don't want to display an error if this was the default file or the cloud storage */
if ((prefs.default_filename && !strcmp(filename, prefs.default_filename)) ||
isCloudUrl(filename))
return 0;
return report_error(translate("gettextFromC", "Failed to read '%s'"), filename);
+ } else if (ret == 0) {
+ return report_error(translate("gettextFromC", "Empty file '%s'"), filename);
}
fmt = strrchr(filename, '.');