summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2003-02-06 17:02:22 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2003-02-06 17:02:22 +0000
commit2425ab3eced773bd04c60441d57e89d56558e57d (patch)
treeaf50e4b904193412ed478a36200d8d906f61727a /src
parentde42a5f53d9bb2fda1e6be9746023e56946c8b1f (diff)
Fix core dump when pltcl_elog is called with wrong number of parameters,
per report from Ian Harding.
Diffstat (limited to 'src')
-rw-r--r--src/pl/tcl/pltcl.c30
1 files changed, 15 insertions, 15 deletions
diff --git a/src/pl/tcl/pltcl.c b/src/pl/tcl/pltcl.c
index 293cbf0caad..f736d016829 100644
--- a/src/pl/tcl/pltcl.c
+++ b/src/pl/tcl/pltcl.c
@@ -31,7 +31,7 @@
* ENHANCEMENTS, OR MODIFICATIONS.
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/pl/tcl/pltcl.c,v 1.66.2.1 2002/11/22 16:25:55 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/pl/tcl/pltcl.c,v 1.66.2.2 2003/02/06 17:02:22 tgl Exp $
*
**********************************************************************/
@@ -1248,7 +1248,7 @@ static int
pltcl_elog(ClientData cdata, Tcl_Interp *interp,
int argc, char *argv[])
{
- int level;
+ volatile int level;
sigjmp_buf save_restart;
/************************************************************
@@ -1257,18 +1257,6 @@ pltcl_elog(ClientData cdata, Tcl_Interp *interp,
if (pltcl_restart_in_progress)
return TCL_ERROR;
- /************************************************************
- * Catch the restart longjmp and begin a controlled
- * return though all interpreter levels if it happens
- ************************************************************/
- memcpy(&save_restart, &Warn_restart, sizeof(save_restart));
- if (sigsetjmp(Warn_restart, 1) != 0)
- {
- memcpy(&Warn_restart, &save_restart, sizeof(Warn_restart));
- pltcl_restart_in_progress = 1;
- return TCL_ERROR;
- }
-
if (argc != 3)
{
Tcl_SetResult(interp, "syntax error - 'elog level msg'",
@@ -1294,17 +1282,29 @@ pltcl_elog(ClientData cdata, Tcl_Interp *interp,
{
Tcl_AppendResult(interp, "Unknown elog level '", argv[1],
"'", NULL);
+ return TCL_ERROR;
+ }
+
+ /************************************************************
+ * Catch the longjmp from elog() and begin a controlled
+ * return though all interpreter levels if it happens
+ ************************************************************/
+ memcpy(&save_restart, &Warn_restart, sizeof(save_restart));
+ if (sigsetjmp(Warn_restart, 1) != 0)
+ {
memcpy(&Warn_restart, &save_restart, sizeof(Warn_restart));
+ pltcl_restart_in_progress = 1;
return TCL_ERROR;
}
/************************************************************
* Call elog(), restore the original restart address
- * and return to the caller (if not catched)
+ * and return to the caller (if no longjmp)
************************************************************/
UTF_BEGIN;
elog(level, "%s", UTF_U2E(argv[2]));
UTF_END;
+
memcpy(&Warn_restart, &save_restart, sizeof(Warn_restart));
return TCL_OK;
}