From 0600b0621af3857b6d2c443528ab026aeb30b5e8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Henrik=20Grubbstr=C3=B6m=20=28Grubba=29?=
 <grubba@grubba.org>
Date: Thu, 4 Apr 2019 13:14:03 +0200
Subject: [PATCH] Compiler: Fix issue with mixing automap and splice.

Thanks to Chris Angelico <rosuav@gmail.com> for the report.

Fixes [LysLysKOM 23258037].
---
 .gitattributes |  1 -
 src/docode.c   | 14 +++++++++++++-
 2 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/.gitattributes b/.gitattributes
index d359ccede6..353b19e462 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -197,7 +197,6 @@ testfont binary
 /src/cyclic.h foreign_ident
 /src/dlopen.c foreign_ident
 /src/dmalloc.h foreign_ident
-/src/docode.c foreign_ident
 /src/docode.h foreign_ident
 /src/dummy_ci.h foreign_ident
 /src/dynamic_buffer.c foreign_ident
diff --git a/src/docode.c b/src/docode.c
index 0953ae9f12..73c255ce45 100644
--- a/src/docode.c
+++ b/src/docode.c
@@ -5,7 +5,7 @@
 \*/
 /**/
 #include "global.h"
-RCSID("$Id: docode.c,v 1.135 2001/09/29 08:47:03 hubbe Exp $");
+RCSID("$Id$");
 #include "las.h"
 #include "program.h"
 #include "pike_types.h"
@@ -513,9 +513,11 @@ static int do_encode_automap_arg_list(node *n,
 	depth++;
       }
       emit0(F_MARK);
+      PUSH_CLEANUP_FRAME(do_pop_mark, 0);
       code_expression(n, 0, "[*]");
       emit1(F_NUMBER, depth);
       emit_apply_builtin("__builtin.automap_marker");
+      POP_AND_DONT_CLEANUP;
       return 1;
     }
   }
@@ -1022,15 +1024,19 @@ static int do_docode2(node *n, INT16 flags)
 	fatal("HELP! FATAL INTERNAL COMPILER ERROR (1)\n");
 #endif
 
+      PUSH_CLEANUP_FRAME(do_pop_mark, 0);
       emit0(F_MARK);
+      PUSH_CLEANUP_FRAME(do_pop_mark, 0);
       emit0(F_MARK);
       emit0(F_LTOSVAL);
       emit1(F_NUMBER, depth);
       emit_apply_builtin("__builtin.automap_marker");
+      POP_AND_DONT_CLEANUP;
       emit_builtin_svalue("`+");
       emit2(F_REARRANGE,1,1);
       emit1(F_NUMBER, 1);
       emit_apply_builtin("__automap__");
+      POP_AND_DONT_CLEANUP;
 
       if(flags & DO_POP)
       {
@@ -1084,15 +1090,19 @@ static int do_docode2(node *n, INT16 flags)
 	fatal("HELP! FATAL INTERNAL COMPILER ERROR (1)\n");
 #endif
 
+      PUSH_CLEANUP_FRAME(do_pop_mark, 0);
       emit0(F_MARK);
+      PUSH_CLEANUP_FRAME(do_pop_mark, 0);
       emit0(F_MARK);
       emit0(F_LTOSVAL);
       emit1(F_NUMBER, depth);
       emit_apply_builtin("__builtin.automap_marker");
+      POP_AND_DONT_CLEANUP;
       emit_builtin_svalue("`-");
       emit2(F_REARRANGE,1,1);
       emit1(F_NUMBER, 1);
       emit_apply_builtin("__automap__");
+      POP_AND_DONT_CLEANUP;
 
       if(flags & DO_POP)
       {
@@ -2150,9 +2160,11 @@ static int do_docode2(node *n, INT16 flags)
 
   case F_AUTO_MAP:
     emit0(F_MARK);
+    PUSH_CLEANUP_FRAME(do_pop_mark, 0);
     code_expression(CAR(n), 0, "automap function");
     do_encode_automap_arg_list(CDR(n),0);
     emit_apply_builtin("__automap__");
+    POP_AND_DONT_CLEANUP;
     return 1;
 
   case F_AUTO_MAP_MARKER:
-- 
GitLab