From 01e9e1a87216a4747d8ae3112dc79fd64ba50e85 Mon Sep 17 00:00:00 2001 From: Sebastian Rasmussen Date: Mon, 1 Oct 2018 17:21:04 +0800 Subject: Dynamically allocate colorspace name, to allow arbitrary lengths. --- source/fitz/colorspace-imp.h | 2 +- source/fitz/colorspace.c | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) (limited to 'source/fitz') diff --git a/source/fitz/colorspace-imp.h b/source/fitz/colorspace-imp.h index fe052baf..52042d4e 100644 --- a/source/fitz/colorspace-imp.h +++ b/source/fitz/colorspace-imp.h @@ -26,7 +26,7 @@ struct fz_colorspace_s { fz_key_storable key_storable; size_t size; - char name[24]; + char *name; enum fz_colorspace_type type; int flags; int n; diff --git a/source/fitz/colorspace.c b/source/fitz/colorspace.c index c5a9a542..78a975a2 100644 --- a/source/fitz/colorspace.c +++ b/source/fitz/colorspace.c @@ -225,6 +225,7 @@ fz_drop_colorspace_imp(fz_context *ctx, fz_storable *cs_) cs->free_data(ctx, cs); for (i = 0; i < FZ_MAX_COLORS; i++) fz_free(ctx, cs->colorant[i]); + fz_free(ctx, cs->name); fz_free(ctx, cs); } @@ -251,7 +252,13 @@ fz_new_colorspace(fz_context *ctx, fz_colorspace *cs = fz_malloc_struct(ctx, fz_colorspace); FZ_INIT_KEY_STORABLE(cs, 1, fz_drop_colorspace_imp); cs->size = sizeof(fz_colorspace) + size; - fz_strlcpy(cs->name, name ? name : "UNKNOWN", sizeof cs->name); + fz_try(ctx) + cs->name = fz_strdup(ctx, name ? name : "UNKNOWN"); + fz_catch(ctx) + { + fz_free(ctx, cs); + fz_rethrow(ctx); + } cs->type = type; cs->flags = flags; cs->n = n; -- cgit v1.2.3