Correctly handle files that contain no slides
authorLaslo Hunhold <dev@frign.de>
Thu, 7 Sep 2017 09:01:10 +0000 (11:01 +0200)
committerMarkus Teich <teichm@fs.tum.de>
Thu, 7 Sep 2017 21:37:00 +0000 (23:37 +0200)
Otherwise, on reloading sent would segfault. Move the check-logic to
load() rather than doing it in main() to prevent other misuses of it in
the future.

sent.c

diff --git a/sent.c b/sent.c
index 0da2bfffdbe018ac1ad5a6c4cabfe32915ac93e1..c50a572c24269769d1a84e1bb584df84278991e1 100644 (file)
--- a/sent.c
+++ b/sent.c
@@ -457,6 +457,9 @@ load(FILE *fp)
                if (!p)
                        break;
        }
+
+       if (!slidecount)
+               die("sent: No slides in file");
 }
 
 void
@@ -695,9 +698,6 @@ main(int argc, char *argv[])
        load(fp);
        fclose(fp);
 
-       if (!slidecount)
-               usage();
-
        xinit();
        run();