summaryrefslogtreecommitdiff
path: root/diff.c
diff options
context:
space:
mode:
authorWerner Almesberger <werner@almesberger.net>2016-08-05 21:02:57 -0300
committerWerner Almesberger <werner@almesberger.net>2016-08-05 21:02:57 -0300
commit12164098658bd4bb80b107d748342f223e62b2a0 (patch)
tree2954ff0d07f96eea0b6db5862791299c4797ee7e /diff.c
parentcb7002960e47960468153249c5d4d6c7a2886981 (diff)
downloadeeshow-12164098658bd4bb80b107d748342f223e62b2a0.tar.gz
eeshow-12164098658bd4bb80b107d748342f223e62b2a0.tar.bz2
eeshow-12164098658bd4bb80b107d748342f223e62b2a0.zip
eeshow/ (file_open, *_parse): return 0 on error (may still exit)
Diffstat (limited to 'diff.c')
-rw-r--r--diff.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/diff.c b/diff.c
index f6e1a23..8f48f4d 100644
--- a/diff.c
+++ b/diff.c
@@ -138,10 +138,13 @@ static void *diff_init(int argc, char *const *argv)
if (argc - optind < 1)
usage(*argv);
- file_open(&sch_file, argv[argc - 1], NULL);
+ if (!file_open(&sch_file, argv[argc - 1], NULL))
+ goto fail_open;
for (arg = optind; arg != argc - 1; arg++)
- lib_parse(&new_lib, argv[arg], &sch_file);
- sch_parse(&new_sch, &sch_file, &new_lib);
+ if (!lib_parse(&new_lib, argv[arg], &sch_file))
+ goto fail_parse;
+ if (!sch_parse(&new_sch, &sch_file, &new_lib))
+ goto fail_parse;
file_close(&sch_file);
optind = 0;
@@ -155,6 +158,14 @@ static void *diff_init(int argc, char *const *argv)
diff->cr_ctx = cro_img_ops.init(argc, argv);
return diff;
+
+fail_parse:
+ file_close(&sch_file);
+fail_open:
+ sch_free(&new_sch);
+ lib_free(&new_lib);
+ free(diff);
+ return NULL;
}