mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-30 22:20:21 +00:00
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>
This commit is contained in:
parent
1f4267d093
commit
e4353cb4a7
1 changed files with 3 additions and 1 deletions
4
file.c
4
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, '.');
|
||||
|
|
Loading…
Reference in a new issue