summaryrefslogtreecommitdiffstatshomepage
path: root/html.c
diff options
context:
space:
mode:
authorKristaps Dzonsons <kristaps@bsd.lv>2009-10-30 18:43:24 +0000
committerKristaps Dzonsons <kristaps@bsd.lv>2009-10-30 18:43:24 +0000
commit6743cd2838c98a6c8127771ac05c6695131f26f5 (patch)
tree71c87689d03cfa48404a4ef86049447f58ae39aa /html.c
parent8caff3a42d43b9b1377f3802a105817dcd4301dc (diff)
downloadmandoc-6743cd2838c98a6c8127771ac05c6695131f26f5.tar.gz
mandoc-6743cd2838c98a6c8127771ac05c6695131f26f5.tar.zst
mandoc-6743cd2838c98a6c8127771ac05c6695131f26f5.zip
Continued safe handling of allocations.
Diffstat (limited to 'html.c')
-rw-r--r--html.c22
1 files changed, 12 insertions, 10 deletions
diff --git a/html.c b/html.c
index 42a649ba..4f02e479 100644
--- a/html.c
+++ b/html.c
@@ -1,4 +1,4 @@
-/* $Id: html.c,v 1.71 2009/10/30 04:57:17 kristaps Exp $ */
+/* $Id: html.c,v 1.72 2009/10/30 18:43:24 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se>
*
@@ -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;