diff options
author | Silvan Jegen <s.jegen@gmail.com> | 2016-09-06 21:05:16 +0200 |
---|---|---|
committer | Silvan Jegen <s.jegen@gmail.com> | 2016-09-06 21:05:16 +0200 |
commit | 8788c5857f7f46eb96350afd3f701bc1082356dd (patch) | |
tree | 0d92537d9e016991f68f92f74cc73e7266cbf484 | |
parent | 22c37e7d908d7f54d4b2d91c5feb77783fa5fd31 (diff) |
Check for NULL
-rw-r--r-- | ezxml.c | 8 |
1 files changed, 6 insertions, 2 deletions
@@ -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"); |