ref: 304420e16947853c697c9f50eb9e7c3cdd64f80c
parent: e641718f01a0a45ec8cfc89602daa345bb9383f8
author: giles <giles@ded80894-8fb9-0310-811b-c03f3676ab4d>
date: Mon Jan 3 23:41:56 EST 2005
Properly free tag and value strings from inside the metadata struct. We now assume we own those pointers, which is fine if jbig2_metadata_add() is used to construct them. git-svn-id: http://svn.ghostscript.com/jbig2dec/trunk@383 ded80894-8fb9-0310-811b-c03f3676ab4d
--- a/jbig2_metadata.c
+++ b/jbig2_metadata.c
@@ -49,8 +49,19 @@
void jbig2_metadata_free(Jbig2Ctx *ctx, Jbig2Metadata *md)
{
- if (md->keys) jbig2_free(ctx->allocator, md->keys);
- if (md->values) jbig2_free(ctx->allocator, md->values);
+ int i;
+
+ if (md->keys) {
+ /* assume we own the pointers */
+ for (i = 0; i < md->entries; i++)
+ jbig2_free(ctx->allocator, md->keys[i]);
+ jbig2_free(ctx->allocator, md->keys);
+ }
+ if (md->values) {
+ for (i = 0; i < md->entries; i++)
+ jbig2_free(ctx->allocator, md->values[i]);
+ jbig2_free(ctx->allocator, md->values);
+ }
jbig2_free(ctx->allocator, md);
}