summaryrefslogtreecommitdiff
path: root/source/fitz
diff options
context:
space:
mode:
authorSebastian Rasmussen <sebras@gmail.com>2018-10-01 17:21:04 +0800
committerTor Andersson <tor.andersson@artifex.com>2018-10-23 18:46:01 +0200
commit01e9e1a87216a4747d8ae3112dc79fd64ba50e85 (patch)
treec8efcd4f76dcdc96ab8fc5adc315e59282378fad /source/fitz
parenta41c299d64c5ab8871a2ddbc4c0ae7b1b1d9e8dc (diff)
downloadmupdf-01e9e1a87216a4747d8ae3112dc79fd64ba50e85.tar.xz
Dynamically allocate colorspace name, to allow arbitrary lengths.
Diffstat (limited to 'source/fitz')
-rw-r--r--source/fitz/colorspace-imp.h2
-rw-r--r--source/fitz/colorspace.c9
2 files changed, 9 insertions, 2 deletions
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;