diff options
author | Kristaps Dzonsons <kristaps@bsd.lv> | 2009-10-30 18:43:24 +0000 |
---|---|---|
committer | Kristaps Dzonsons <kristaps@bsd.lv> | 2009-10-30 18:43:24 +0000 |
commit | ea8cd0ee934ae86efb80393ca7b51e913e55043f (patch) | |
tree | bcb6bc3fb271ba628322b5e83d21979abc00ba5d /html.c | |
parent | e46c16c46ad18d40f21b251bf8995387efa68796 (diff) | |
download | mandoc-ea8cd0ee934ae86efb80393ca7b51e913e55043f.tar.gz |
Continued safe handling of allocations.
Diffstat (limited to 'html.c')
-rw-r--r-- | html.c | 20 |
1 files changed, 11 insertions, 9 deletions
@@ -100,16 +100,15 @@ html_alloc(char *outopts) toks[2] = "includes"; toks[3] = NULL; - if (NULL == (h = calloc(1, sizeof(struct html)))) - return(NULL); + h = calloc(1, sizeof(struct html)); + if (NULL == h) { + fprintf(stderr, "memory exhausted\n"); + exit(EXIT_FAILURE); + } h->tags.head = NULL; h->ords.head = NULL; - - if (NULL == (h->symtab = chars_init(CHARS_HTML))) { - free(h); - return(NULL); - } + h->symtab = chars_init(CHARS_HTML); while (outopts && *outopts) switch (getsubopt(&outopts, UNCONST(toks), &v)) { @@ -354,8 +353,11 @@ print_otag(struct html *h, enum htmltag tag, struct tag *t; if ( ! (HTML_NOSTACK & htmltags[tag].flags)) { - if (NULL == (t = malloc(sizeof(struct tag)))) - err(EXIT_FAILURE, "malloc"); + t = malloc(sizeof(struct tag)); + if (NULL == t) { + fprintf(stderr, "memory exhausted\n"); + exit(EXIT_FAILURE); + } t->tag = tag; t->next = h->tags.head; h->tags.head = t; |