diff options
author | Tor Andersson <tor@ghostscript.com> | 2011-01-27 22:35:26 +0000 |
---|---|---|
committer | Tor Andersson <tor@ghostscript.com> | 2011-01-27 22:35:26 +0000 |
commit | 3802ebf92723382070258bcd43771b2f4186c03f (patch) | |
tree | cb0ca60a270dd9b73918015ee8e8cd86b1dc0296 /apps/pdfclean.c | |
parent | 836d6cb3d16e94929be98c000a35255a5ffe37ff (diff) | |
download | mupdf-3802ebf92723382070258bcd43771b2f4186c03f.tar.xz |
Add fz_calloc function to check for integer overflow when allocating arrays, and change the signature of fz_realloc to match.
Diffstat (limited to 'apps/pdfclean.c')
-rw-r--r-- | apps/pdfclean.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/apps/pdfclean.c b/apps/pdfclean.c index fbea8fd4..8f51157a 100644 --- a/apps/pdfclean.c +++ b/apps/pdfclean.c @@ -241,7 +241,7 @@ static void renumberobjs(void) /* Create new table for the reordered, compacted xref */ oldxref = xref->table; - xref->table = fz_malloc(xref->len * sizeof (pdf_xrefentry)); + xref->table = fz_calloc(xref->len, sizeof(pdf_xrefentry)); xref->table[0] = oldxref[0]; /* Move used objects into the new compacted xref */ @@ -721,10 +721,10 @@ int main(int argc, char **argv) fprintf(out, "%%PDF-%d.%d\n", xref->version / 10, xref->version % 10); fprintf(out, "%%\316\274\341\277\246\n\n"); - uselist = fz_malloc(sizeof (char) * (xref->len + 1)); - ofslist = fz_malloc(sizeof (int) * (xref->len + 1)); - genlist = fz_malloc(sizeof (int) * (xref->len + 1)); - renumbermap = fz_malloc(sizeof (int) * (xref->len + 1)); + uselist = fz_calloc(xref->len + 1, sizeof(char)); + ofslist = fz_calloc(xref->len + 1, sizeof(int)); + genlist = fz_calloc(xref->len + 1, sizeof(int)); + renumbermap = fz_calloc(xref->len + 1, sizeof(int)); for (num = 0; num < xref->len; num++) { |