diff options
author | Ingo Schwarze <schwarze@openbsd.org> | 2014-04-23 21:06:41 +0000 |
---|---|---|
committer | Ingo Schwarze <schwarze@openbsd.org> | 2014-04-23 21:06:41 +0000 |
commit | d14278c71c190ee93f3a8fbe0db5fe9f64fcee24 (patch) | |
tree | b979660d5a5719053862183ee172a781e317d0ba /term_ps.c | |
parent | bd8fc166fb7a4aad04578dee7fe7fc209d5e1488 (diff) | |
download | mandoc-d14278c71c190ee93f3a8fbe0db5fe9f64fcee24.tar.gz |
Audit malloc(3)/calloc(3)/realloc(3) usage.
* Change eight reallocs to reallocarray to be safe from overflows.
* Change one malloc to reallocarray to be safe from overflows.
* Change one calloc to reallocarray, no zeroing needed.
* Change the order of arguments of three callocs (aesthetical).
Diffstat (limited to 'term_ps.c')
-rw-r--r-- | term_ps.c | 12 |
1 files changed, 3 insertions, 9 deletions
@@ -628,12 +628,8 @@ pdf_obj(struct termp *p, size_t obj) if ((obj - 1) >= p->ps->pdfobjsz) { p->ps->pdfobjsz = obj + 128; - p->ps->pdfobjs = realloc(p->ps->pdfobjs, - p->ps->pdfobjsz * sizeof(size_t)); - if (NULL == p->ps->pdfobjs) { - perror(NULL); - exit((int)MANDOCLEVEL_SYSERR); - } + p->ps->pdfobjs = mandoc_reallocarray(p->ps->pdfobjs, + p->ps->pdfobjsz, sizeof(size_t)); } p->ps->pdfobjs[(int)obj - 1] = p->ps->pdfbytes; @@ -1169,7 +1165,5 @@ ps_growbuf(struct termp *p, size_t sz) sz = PS_BUFSLOP; p->ps->psmargsz += sz; - - p->ps->psmarg = mandoc_realloc - (p->ps->psmarg, p->ps->psmargsz); + p->ps->psmarg = mandoc_realloc(p->ps->psmarg, p->ps->psmargsz); } |