]> git.imager.perl.org - imager.git/commitdiff
properly initialize slot_alloc in context objects
authorTony Cook <tony@develop-help.com>
Tue, 18 Sep 2012 01:52:14 +0000 (11:52 +1000)
committerTony Cook <tony@develop-help.com>
Tue, 18 Sep 2012 01:52:14 +0000 (11:52 +1000)
context.c

index 3e0ab769fa52fbd9842c1f1b0b64f755ed3436ab..0dd70625d26e27cefcc18744dd6d39f353153bad 100644 (file)
--- a/context.c
+++ b/context.c
@@ -38,7 +38,8 @@ im_context_new(void) {
   ctx->max_height = 0;
   ctx->max_bytes = DEF_BYTES_LIMIT;
 
-  ctx->slots = calloc(sizeof(void *), slot_count);
+  ctx->slot_alloc = slot_count;
+  ctx->slots = calloc(sizeof(void *), ctx->slot_alloc);
   if (!ctx->slots) {
     free(ctx);
     return NULL;
@@ -139,12 +140,12 @@ im_context_clone(im_context_t ctx, const char *where) {
   if (!nctx)
     return NULL;
 
-  nctx->slots = calloc(sizeof(void *), slot_count);
+  nctx->slot_alloc = slot_count;
+  nctx->slots = calloc(sizeof(void *), ctx->slot_alloc);
   if (!nctx->slots) {
     free(nctx);
     return NULL;
   }
-  nctx->slot_alloc = slot_count;
 
   nctx->error_sp = ctx->error_sp;
   for (i = 0; i < IM_ERROR_COUNT; ++i) {