diff --git a/src/interpret.c b/src/interpret.c
index a834b33329de06c8706ee707433c57055e7bd896..91a941d000df82513026fe5ba3ea05733e3e7dff 100644
--- a/src/interpret.c
+++ b/src/interpret.c
@@ -2,11 +2,11 @@
 || This file is part of Pike. For copyright information see COPYRIGHT.
 || Pike is distributed under GPL, LGPL and MPL. See the file COPYING
 || for more information.
-|| $Id: interpret.c,v 1.331 2003/09/24 00:57:58 mast Exp $
+|| $Id: interpret.c,v 1.332 2003/09/26 17:38:12 grubba Exp $
 */
 
 #include "global.h"
-RCSID("$Id: interpret.c,v 1.331 2003/09/24 00:57:58 mast Exp $");
+RCSID("$Id: interpret.c,v 1.332 2003/09/26 17:38:12 grubba Exp $");
 #include "interpret.h"
 #include "object.h"
 #include "program.h"
@@ -137,8 +137,22 @@ void gc_mark_stack_external (struct pike_frame *f,
       gc_mark_external (f->current_object, " in current_object in frame on stack");
       gc_mark_external (f->context.prog, " in context.prog in frame on stack");
       if (f->locals) {		/* Check really needed? */
-	gc_mark_external_svalues (f->locals, stack_p - f->locals, " on svalue stack");
-	stack_p = f->locals;
+	if (f->flags & PIKE_FRAME_MALLOCED_LOCALS) {
+	  /* FIXME: In this case the frame is an object;
+	   *        Are we counting double?
+	   */
+	  gc_mark_external_svalues(f->locals, f->num_locals,
+				   " in malloced locals");
+	} else {
+	  /* NOTE: stack_fp may be less than f->locals. */
+	  if ((stack_p - f->locals) >= 0x10000) {
+	    fatal("Unreasonable locals: stack:%p locals:%p\n",
+		  stack_p, f->locals);
+	  }
+	  gc_mark_external_svalues (f->locals, stack_p - f->locals, " on svalue stack");
+	  /* FIXME: Is this safe if stack_p is less than f->locals? */
+	  stack_p = f->locals;
+	}
       }
     } GC_LEAVE;
   if (stack != stack_p)