summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSilvan Jegen <s.jegen@gmail.com>2016-09-06 21:05:16 +0200
committerSilvan Jegen <s.jegen@gmail.com>2016-09-06 21:05:16 +0200
commit8788c5857f7f46eb96350afd3f701bc1082356dd (patch)
tree0d92537d9e016991f68f92f74cc73e7266cbf484
parent22c37e7d908d7f54d4b2d91c5feb77783fa5fd31 (diff)
Check for NULL
-rw-r--r--ezxml.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/ezxml.c b/ezxml.c
index b02400f..b267b40 100644
--- a/ezxml.c
+++ b/ezxml.c
@@ -16,11 +16,15 @@ int process(char *fn) {
ezxml_t body = ezxml_get(ezdoc, "body", -1);
if (!body) {
- fprintf(stderr, "No body-tag found in file '%s'\n", fn);
+ fprintf(stderr, "No body-tag found in file '%s'. Exiting.\n", fn);
+ return 1;
}
+
for (ezxml_t c = ezxml_child(body, "sec"); c; c = c->next) {
ezxml_t t = ezxml_get(c, "title", -1);
- printf("section-title: %s\n", t->txt);
+ if (t) {
+ printf("section-title: %s\n", t->txt);
+ }
}
printf("\n");