don't clone the error stack
authorTony Cook <tony@develop-help.com>
Sat, 27 Oct 2012 01:18:13 +0000 (12:18 +1100)
committerTony Cook <tony@develop-help.com>
Sat, 24 Nov 2012 04:05:55 +0000 (15:05 +1100)
context.c

index 4645ebf5dd83414615be1a8189e8b587e5615d12..75fcd944c9b39d550c236f149bf98aba6f9b8d8e 100644 (file)
--- a/context.c
+++ b/context.c
@@ -128,6 +128,8 @@ im_context_refdec(im_context_t ctx, const char *where) {
 
 Clone an Imager context object, returning the result.
 
+The error stack is not copied from the original context.
+
 =cut
 */
 
@@ -146,19 +148,10 @@ im_context_clone(im_context_t ctx, const char *where) {
   }
   nctx->slot_alloc = slot_count;
 
-  nctx->error_sp = ctx->error_sp;
+  nctx->error_sp = IM_ERROR_COUNT-1;
   for (i = 0; i < IM_ERROR_COUNT; ++i) {
-    if (ctx->error_stack[i].msg) {
-      size_t sz = ctx->error_alloc[i];
-      nctx->error_alloc[i] = sz;
-      nctx->error_stack[i].msg = mymalloc(sz);
-      memcpy(nctx->error_stack[i].msg, ctx->error_stack[i].msg, sz);
-    }
-    else {
-      nctx->error_alloc[i] = 0;
-      nctx->error_stack[i].msg = NULL;
-    }
-    nctx->error_stack[i].code = ctx->error_stack[i].code;
+    nctx->error_alloc[i] = 0;
+    nctx->error_stack[i].msg = NULL;
   }
 #ifdef IMAGER_LOG
   nctx->log_level = ctx->log_level;