diff --git a/src/builtin_functions.c b/src/builtin_functions.c
index bd8f812610fcce672a326224e53b3762622e38bc..13c263b1428541fa0358127755c92be63aeefab4 100644
--- a/src/builtin_functions.c
+++ b/src/builtin_functions.c
@@ -5,7 +5,7 @@
 \*/
 /**/
 #include "global.h"
-RCSID("$Id: builtin_functions.c,v 1.389 2001/07/02 07:02:44 hubbe Exp $");
+RCSID("$Id: builtin_functions.c,v 1.390 2001/07/02 20:09:16 mast Exp $");
 #include "interpret.h"
 #include "svalue.h"
 #include "pike_macros.h"
@@ -3140,6 +3140,8 @@ node *optimize_replace(node *n)
 	if (SETJMP(tmp)) {
 	  yywarning("Optimizer failure in replace().");
 	  pop_n_elems(Pike_sp - save_sp);
+	  free_svalue(&throw_value);
+	  throw_value.type = T_INT;
 	} else {
 	  extern struct program *multi_string_replace_program;
 	  INT16 lfun;
diff --git a/src/cpp.c b/src/cpp.c
index 2b78836c408ab9d6c847829abb1c41e6221145a1..c1e2bf9489b58cbb63b16e9ecfee308c2234d984 100644
--- a/src/cpp.c
+++ b/src/cpp.c
@@ -5,7 +5,7 @@
 \*/
 
 /*
- * $Id: cpp.c,v 1.89 2001/06/14 19:28:08 grubba Exp $
+ * $Id: cpp.c,v 1.90 2001/07/02 20:09:16 mast Exp $
  */
 #include "global.h"
 #include "stralloc.h"
@@ -1225,6 +1225,8 @@ static int do_safe_index_call(struct pike_string *s)
   
   if (SETJMP(recovery)) {
     res = 0;
+    free_svalue(&throw_value);
+    throw_value.type = T_INT;
   } else {
     ref_push_string(s);
     f_index(2);
diff --git a/src/interpret.c b/src/interpret.c
index 1947a0e008cb20344d76ad4317220acdf2e2047c..c529a3bdd315f400b6d3868a89f7802b48e34fe1 100644
--- a/src/interpret.c
+++ b/src/interpret.c
@@ -5,7 +5,7 @@
 \*/
 /**/
 #include "global.h"
-RCSID("$Id: interpret.c,v 1.211 2001/07/02 04:09:48 hubbe Exp $");
+RCSID("$Id: interpret.c,v 1.212 2001/07/02 20:09:17 mast Exp $");
 #include "interpret.h"
 #include "object.h"
 #include "program.h"
@@ -1619,7 +1619,7 @@ PMOD_EXPORT int apply_low_safe_and_stupid(struct object *o, INT32 offset)
   return ret;
 }
 
-PMOD_EXPORT void safe_apply_low(struct object *o,int fun,int args)
+PMOD_EXPORT void safe_apply_low2(struct object *o,int fun,int args, int handle_errors)
 {
   JMP_BUF recovery;
 
@@ -1628,8 +1628,7 @@ PMOD_EXPORT void safe_apply_low(struct object *o,int fun,int args)
   throw_value.type=T_INT;
   if(SETJMP(recovery))
   {
-    if(throw_value.type != T_INT)
-      call_handle_error();
+    if(handle_errors) call_handle_error();
     Pike_sp->u.integer = 0;
     Pike_sp->subtype=NUMBER_NUMBER;
     Pike_sp->type = T_INT;
@@ -1651,13 +1650,17 @@ PMOD_EXPORT void safe_apply_low(struct object *o,int fun,int args)
   UNSETJMP(recovery);
 }
 
+PMOD_EXPORT void safe_apply_low(struct object *o,int fun,int args)
+{
+  safe_apply_low2(o, fun, args, 1);
+}
 
 PMOD_EXPORT void safe_apply(struct object *o, char *fun ,INT32 args)
 {
 #ifdef PIKE_DEBUG
   if(!o->prog) fatal("Apply safe on destructed object.\n");
 #endif
-  safe_apply_low(o, find_identifier(fun, o->prog), args);
+  safe_apply_low2(o, find_identifier(fun, o->prog), args, 1);
 }
 
 PMOD_EXPORT void safe_apply_handler(const char *fun,
@@ -1666,16 +1669,22 @@ PMOD_EXPORT void safe_apply_handler(const char *fun,
 				    INT32 args)
 {
   int i;
+  free_svalue(&throw_value);
+  throw_value.type = T_INT;
   if (handler && handler->prog &&
       (i = find_identifier(fun, handler->prog)) != -1) {
-    safe_apply_low(handler, i, args);
+    safe_apply_low2(handler, i, args, 0);
   } else if (compat && compat->prog &&
 	     (i = find_identifier(fun, compat->prog)) != -1) {
-    safe_apply_low(compat, i, args);
+    safe_apply_low2(compat, i, args, 0);
   } else {
     struct object *master_obj = master();
     i = find_identifier(fun, master_obj->prog);
-    safe_apply_low(master_obj, i, args);
+    safe_apply_low2(master_obj, i, args, 0);
+  }
+  if (throw_value.type != T_STRING && throw_value.type != T_INT) {
+    free_svalue(&throw_value);
+    throw_value.type = T_INT;
   }
 }
 
diff --git a/src/interpret.h b/src/interpret.h
index 197f902d0c2b4b1de06095962bd6075199990579..4bcd0c97d09b647741e3eca64373b1dc17be738a 100644
--- a/src/interpret.h
+++ b/src/interpret.h
@@ -5,7 +5,7 @@
 \*/
 
 /*
- * $Id: interpret.h,v 1.90 2001/06/29 23:33:30 hubbe Exp $
+ * $Id: interpret.h,v 1.91 2001/07/02 20:09:17 mast Exp $
  */
 #ifndef INTERPRET_H
 #define INTERPRET_H
@@ -266,7 +266,7 @@ do{ \
     fun_=find_identifier(FUN,master_ob->prog); \
     master_cnt = master_ob->prog->id; \
   } \
-  safe_apply_low(master_ob, fun_, ARGS); \
+  safe_apply_low2(master_ob, fun_, ARGS, 1); \
 }while(0)
 
 #define SAFE_APPLY_HANDLER(FUN, HANDLER, COMPAT, ARGS) do {	\
@@ -332,6 +332,7 @@ PMOD_EXPORT void f_call_function(INT32 args);
 PMOD_EXPORT void call_handle_error(void);
 PMOD_EXPORT int apply_low_safe_and_stupid(struct object *o, INT32 offset);
 PMOD_EXPORT void safe_apply_low(struct object *o,int fun,int args);
+PMOD_EXPORT void safe_apply_low2(struct object *o,int fun,int args, int handle_errors);
 PMOD_EXPORT void safe_apply(struct object *o, char *fun ,INT32 args);
 PMOD_EXPORT void safe_apply_handler(const char *fun,
 				    struct object *handler,
diff --git a/src/language.yacc b/src/language.yacc
index 8637a18f0c1e28583751401b3403be9327201b7a..ef8e57cdf3bf933d045a7eb3f4584b8b7a33f37c 100644
--- a/src/language.yacc
+++ b/src/language.yacc
@@ -112,7 +112,7 @@
 /* This is the grammar definition of Pike. */
 
 #include "global.h"
-RCSID("$Id: language.yacc,v 1.254 2001/06/30 22:11:09 mast Exp $");
+RCSID("$Id: language.yacc,v 1.255 2001/07/02 20:09:17 mast Exp $");
 #ifdef HAVE_MEMORY_H
 #include <memory.h>
 #endif
@@ -3833,9 +3833,9 @@ static void safe_inc_enum(void)
   struct svalue *save_sp = Pike_sp;
   JMP_BUF recovery;
 
-  free_svalue(&throw_value);
-  throw_value.type = T_INT;
   if (SETJMP(recovery)) {
+    free_svalue(&throw_value);
+    throw_value.type = T_INT;
     yyerror("Bad implicit enum value (failed to add 1).");
     while(Pike_sp > save_sp) pop_stack();
   } else {
diff --git a/src/las.c b/src/las.c
index a840f0c022692d55efdb571ad98ded697ef8d322..34c1b992f29ba6a12011f85e92b3ce03d081a5ee 100644
--- a/src/las.c
+++ b/src/las.c
@@ -5,7 +5,7 @@
 \*/
 /**/
 #include "global.h"
-RCSID("$Id: las.c,v 1.254 2001/06/23 21:52:09 hubbe Exp $");
+RCSID("$Id: las.c,v 1.255 2001/07/02 20:09:17 mast Exp $");
 
 #include "language.h"
 #include "interpret.h"
@@ -1752,6 +1752,8 @@ node *index_node(node *n, char *node_name, struct pike_string *id)
 	     *
 	     * FIXME: Report the error thrown.
 	     */
+	    free_svalue(&throw_value);
+	    throw_value.type = T_INT;
 	    if (Pike_sp > save_sp) {
 	      pop_n_elems(Pike_sp - save_sp);
 	    } else if (Pike_sp != save_sp) {
@@ -4998,6 +5000,8 @@ ptrdiff_t eval_low(node *n)
 	  yyerror("Nonstandard error format.");
 	}
       }
+      free_svalue(&throw_value);
+      throw_value.type = T_INT;
     }else{
       if(foo.yes)
 	pop_n_elems(Pike_sp-save_sp);
diff --git a/src/mapping.c b/src/mapping.c
index d8243ecc89a026d69016afb4661e94d6d9b8e351..ff1df7d3ce097e86309b4c3c1db9cf878ec344d6 100644
--- a/src/mapping.c
+++ b/src/mapping.c
@@ -5,7 +5,7 @@
 \*/
 /**/
 #include "global.h"
-RCSID("$Id: mapping.c,v 1.128 2001/07/01 21:34:51 mast Exp $");
+RCSID("$Id: mapping.c,v 1.129 2001/07/02 20:09:18 mast Exp $");
 #include "main.h"
 #include "object.h"
 #include "mapping.h"
@@ -1650,7 +1650,11 @@ void describe_mapping(struct mapping *m,struct processing *p,int indent)
     }
 
     t_flag = 0;
-    if(!SETJMP(catch))
+    if(SETJMP(catch)) {
+      free_svalue(&throw_value);
+      throw_value.type = T_INT;
+    }
+    else
       sort_array_destructively(a);
     UNSETJMP(catch);
     t_flag = save_t_flag;
diff --git a/src/modules/Java/jvm.c b/src/modules/Java/jvm.c
index 1d9a311d6a8471345aa1d15c0a4b891e8a365dfe..f47d42767684751cd73b86ef431d77610bead8c4 100644
--- a/src/modules/Java/jvm.c
+++ b/src/modules/Java/jvm.c
@@ -1,5 +1,5 @@
 /*
- * $Id: jvm.c,v 1.33 2001/04/23 22:17:32 marcus Exp $
+ * $Id: jvm.c,v 1.34 2001/07/02 20:09:07 mast Exp $
  *
  * Pike interface to Java Virtual Machine
  *
@@ -17,7 +17,7 @@
 #endif /* HAVE_CONFIG_H */
 
 #include "global.h"
-RCSID("$Id: jvm.c,v 1.33 2001/04/23 22:17:32 marcus Exp $");
+RCSID("$Id: jvm.c,v 1.34 2001/07/02 20:09:07 mast Exp $");
 #include "program.h"
 #include "interpret.h"
 #include "stralloc.h"
@@ -1636,6 +1636,8 @@ static void do_native_dispatch(struct native_method_context *ctx,
     make_java_exception(ctx->nat->jvm, env, &throw_value);
     pop_n_elems(Pike_sp-osp);
     UNSETJMP(recovery);
+    free_svalue(&throw_value);
+    throw_value.type = PIKE_T_INT;
     return;
   }
 
diff --git a/src/object.c b/src/object.c
index 7a38296e02766635c01af6e35af389e69fb0a1a5..3386be3a919562f52bccf59f99674605aa538823 100644
--- a/src/object.c
+++ b/src/object.c
@@ -5,7 +5,7 @@
 \*/
 /**/
 #include "global.h"
-RCSID("$Id: object.c,v 1.175 2001/07/01 18:29:58 mast Exp $");
+RCSID("$Id: object.c,v 1.176 2001/07/02 20:09:18 mast Exp $");
 #include "object.h"
 #include "dynamic_buffer.h"
 #include "interpret.h"
@@ -408,6 +408,8 @@ PMOD_EXPORT struct object *get_master(void)
 #endif
 	/* do nothing */
 	UNSETJMP(tmp);
+	free_svalue(&throw_value);
+	throw_value.type = T_INT;
       }else{
 	f_decode_value(2);
 	UNSETJMP(tmp);
@@ -513,7 +515,7 @@ static void call_destroy(struct object *o, int foo)
 		o, o->refs);
 #endif
       if(foo) push_int(1);
-      safe_apply_low(o, e, foo?1:0);
+      safe_apply_low2(o, e, foo?1:0, 1);
       pop_stack();
 #ifdef GC_VERBOSE
       if (Pike_in_gc > GC_PASS_PREPARE)
diff --git a/src/pike_error.h b/src/pike_error.h
index cc479f5020640dbb7ac7eb1de45751e40e51651f..d7a42ae5f5a557985864119f4ee2916eb61e0344 100644
--- a/src/pike_error.h
+++ b/src/pike_error.h
@@ -5,7 +5,7 @@
 \*/
 
 /*
- * $Id: pike_error.h,v 1.11 2001/03/28 10:02:42 hubbe Exp $
+ * $Id: pike_error.h,v 1.12 2001/07/02 20:09:18 mast Exp $
  */
 #ifndef PIKE_ERROR_H
 #define PIKE_ERROR_H
@@ -294,7 +294,11 @@ void cleanup_error(void);
 #define exception_endtry \
             else \
                 __exception_rethrow = 1; \
-            if(!__is_exception) \
+            if(__is_exception) { \
+		free_svalue(&throw_value); \
+		throw_value.type = T_INT; \
+	    } \
+	    else \
                 UNSETJMP(exception); \
             if(__exception_rethrow) \
                 rethrow; \
diff --git a/src/preprocessor.h b/src/preprocessor.h
index 400b795928373e97482d871a97a875aed6a4251c..53097bcbdef5384772eb8b3a4ea2571f5f76e110 100644
--- a/src/preprocessor.h
+++ b/src/preprocessor.h
@@ -1,5 +1,5 @@
 /*
- * $Id: preprocessor.h,v 1.42 2001/06/07 20:16:26 grubba Exp $
+ * $Id: preprocessor.h,v 1.43 2001/07/02 20:09:18 mast Exp $
  *
  * Preprocessor template.
  * Based on cpp.c 1.45
@@ -764,6 +764,8 @@ static ptrdiff_t calc(struct cpp *this, WCHAR *data, ptrdiff_t len,
     }else{
       cpp_error(this, "Nonstandard error format.");
     }
+    free_svalue(&throw_value);
+    throw_value.type = T_INT;
     FIND_EOL();
     push_int(0);
   }else{
diff --git a/src/svalue.c b/src/svalue.c
index c4be8fcc42d3f910c6e73b164bcb68dd2a735206..92202b3b381be626680887e7ba8bba172ff5355d 100644
--- a/src/svalue.c
+++ b/src/svalue.c
@@ -62,7 +62,7 @@ static int pike_isnan(double x)
 #endif /* HAVE__ISNAN */
 #endif /* HAVE_ISNAN */
 
-RCSID("$Id: svalue.c,v 1.109 2001/07/01 21:34:51 mast Exp $");
+RCSID("$Id: svalue.c,v 1.110 2001/07/02 20:09:18 mast Exp $");
 
 struct svalue dest_ob_zero = {
   T_INT, 0,
@@ -487,7 +487,7 @@ PMOD_EXPORT unsigned INT32 hash_svalue(const struct svalue *s)
 
     if(FIND_LFUN(s->u.object->prog,LFUN___HASH) != -1)
     {
-      safe_apply_low(s->u.object, FIND_LFUN(s->u.object->prog,LFUN___HASH), 0);
+      safe_apply_low2(s->u.object, FIND_LFUN(s->u.object->prog,LFUN___HASH), 0, 1);
       if(sp[-1].type == T_INT)
       {
 	q=sp[-1].u.integer;
@@ -533,7 +533,7 @@ PMOD_EXPORT int svalue_is_true(const struct svalue *s)
 
     if(FIND_LFUN(s->u.object->prog,LFUN_NOT)!=-1)
     {
-      safe_apply_low(s->u.object,FIND_LFUN(s->u.object->prog,LFUN_NOT),0);
+      safe_apply_low2(s->u.object,FIND_LFUN(s->u.object->prog,LFUN_NOT),0,1);
       if(sp[-1].type == T_INT && sp[-1].u.integer == 0)
       {
 	pop_stack();
@@ -1076,7 +1076,7 @@ PMOD_EXPORT void describe_svalue(const struct svalue *s,int indent,struct proces
 	  push_constant_text("indent");
 	  push_int(indent);
 	  f_aggregate_mapping(2);					      
-	  safe_apply_low(s->u.object, fun ,2);
+	  safe_apply_low2(s->u.object, fun ,2,1);
 
 	  if(!IS_ZERO(sp-1))
 	  {