diff options
author | Robin Watts <robin.watts@artifex.com> | 2012-04-05 18:01:54 +0100 |
---|---|---|
committer | Robin Watts <robin.watts@artifex.com> | 2012-04-05 18:26:34 +0100 |
commit | e7b13e1de4b29f36ed536bb863e5d81768550490 (patch) | |
tree | 82b9645887a4eb1223f49e76f4f8872204019fa0 /apps/mupdfinfo.c | |
parent | ff55e72b741b955bbd0e23bd9d724c6682a181ac (diff) | |
download | mupdf-e7b13e1de4b29f36ed536bb863e5d81768550490.tar.xz |
Fix potential problems on malloc failure.
Don't reset the size of arrays until we have successfully resized them.
Diffstat (limited to 'apps/mupdfinfo.c')
-rw-r--r-- | apps/mupdfinfo.c | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/apps/mupdfinfo.c b/apps/mupdfinfo.c index e02d8d1a..a54f92bd 100644 --- a/apps/mupdfinfo.c +++ b/apps/mupdfinfo.c @@ -209,9 +209,9 @@ gatherdimensions(int page, pdf_obj *pageref, pdf_obj *pageobj) if (j < dims) return; + dim = fz_resize_array(ctx, dim, dims+1, sizeof(struct info)); dims++; - dim = fz_resize_array(ctx, dim, dims, sizeof(struct info)); dim[dims - 1].page = page; dim[dims - 1].pageref = pageref; dim[dims - 1].pageobj = pageobj; @@ -254,9 +254,9 @@ gatherfonts(int page, pdf_obj *pageref, pdf_obj *pageobj, pdf_obj *dict) if (k < fonts) continue; + font = fz_resize_array(ctx, font, fonts+1, sizeof(struct info)); fonts++; - font = fz_resize_array(ctx, font, fonts, sizeof(struct info)); font[fonts - 1].page = page; font[fonts - 1].pageref = pageref; font[fonts - 1].pageobj = pageobj; @@ -323,9 +323,9 @@ gatherimages(int page, pdf_obj *pageref, pdf_obj *pageobj, pdf_obj *dict) if (k < images) continue; + image = fz_resize_array(ctx, image, images+1, sizeof(struct info)); images++; - image = fz_resize_array(ctx, image, images, sizeof(struct info)); image[images - 1].page = page; image[images - 1].pageref = pageref; image[images - 1].pageobj = pageobj; @@ -381,9 +381,9 @@ gatherforms(int page, pdf_obj *pageref, pdf_obj *pageobj, pdf_obj *dict) if (k < forms) continue; + form = fz_resize_array(ctx, form, forms+1, sizeof(struct info)); forms++; - form = fz_resize_array(ctx, form, forms, sizeof(struct info)); form[forms - 1].page = page; form[forms - 1].pageref = pageref; form[forms - 1].pageobj = pageobj; @@ -426,9 +426,9 @@ gatherpsobjs(int page, pdf_obj *pageref, pdf_obj *pageobj, pdf_obj *dict) if (k < psobjs) continue; + psobj = fz_resize_array(ctx, psobj, psobjs+1, sizeof(struct info)); psobjs++; - psobj = fz_resize_array(ctx, psobj, psobjs, sizeof(struct info)); psobj[psobjs - 1].page = page; psobj[psobjs - 1].pageref = pageref; psobj[psobjs - 1].pageobj = pageobj; @@ -469,9 +469,9 @@ gathershadings(int page, pdf_obj *pageref, pdf_obj *pageobj, pdf_obj *dict) if (k < shadings) continue; + shading = fz_resize_array(ctx, shading, shadings+1, sizeof(struct info)); shadings++; - shading = fz_resize_array(ctx, shading, shadings, sizeof(struct info)); shading[shadings - 1].page = page; shading[shadings - 1].pageref = pageref; shading[shadings - 1].pageobj = pageobj; @@ -537,9 +537,9 @@ gatherpatterns(int page, pdf_obj *pageref, pdf_obj *pageobj, pdf_obj *dict) if (k < patterns) continue; + pattern = fz_resize_array(ctx, pattern, patterns+1, sizeof(struct info)); patterns++; - pattern = fz_resize_array(ctx, pattern, patterns, sizeof(struct info)); pattern[patterns - 1].page = page; pattern[patterns - 1].pageref = pageref; pattern[patterns - 1].pageobj = pageobj; |