summaryrefslogtreecommitdiff
path: root/xps/xpszip.c
diff options
context:
space:
mode:
authorTor Andersson <tor.andersson@artifex.com>2011-03-30 16:00:59 +0200
committerTor Andersson <tor.andersson@artifex.com>2011-03-30 16:00:59 +0200
commita903a2ed5572b86deb323cb5471520aba05a0189 (patch)
tree6924a0051858f2ed6281d216c073bbdebaec4ff2 /xps/xpszip.c
parent59ff521faa134a5bd2c4de3621eeadc98d272bac (diff)
downloadmupdf-a903a2ed5572b86deb323cb5471520aba05a0189.tar.xz
xps: Use fz_calloc for array allocations.
Diffstat (limited to 'xps/xpszip.c')
-rw-r--r--xps/xpszip.c10
1 files changed, 2 insertions, 8 deletions
diff --git a/xps/xpszip.c b/xps/xpszip.c
index a02ce302..5528f0f7 100644
--- a/xps/xpszip.c
+++ b/xps/xpszip.c
@@ -22,7 +22,7 @@ static inline int getlong(FILE *file)
static void *
xps_zip_alloc_items(xps_context *ctx, int items, int size)
{
- return fz_malloc(items * size);
+ return fz_calloc(items, size);
}
static void
@@ -159,10 +159,7 @@ xps_read_zip_dir(xps_context *ctx, int start_offset)
offset = getlong(ctx->file); /* offset to central directory */
ctx->zip_count = count;
- ctx->zip_table = fz_malloc(sizeof(xps_entry) * count);
- if (!ctx->zip_table)
- return fz_throw("cannot allocate zip entry table");
-
+ ctx->zip_table = fz_calloc(count, sizeof(xps_entry));
memset(ctx->zip_table, 0, sizeof(xps_entry) * count);
fseek(ctx->file, offset, 0);
@@ -191,9 +188,6 @@ xps_read_zip_dir(xps_context *ctx, int start_offset)
ctx->zip_table[i].offset = getlong(ctx->file);
ctx->zip_table[i].name = fz_malloc(namesize + 1);
- if (!ctx->zip_table[i].name)
- return fz_throw("cannot allocate zip entry name");
-
fread(ctx->zip_table[i].name, 1, namesize, ctx->file);
ctx->zip_table[i].name[namesize] = 0;