Skip to content

Commit 465ed56

Browse files
committed
Fix core dump when pltcl_elog is called with wrong number of parameters,
per report from Ian Harding.
1 parent e24977f commit 465ed56

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

src/pl/tcl/pltcl.c

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
* ENHANCEMENTS, OR MODIFICATIONS.
3232
*
3333
* IDENTIFICATION
34-
* $Header: /cvsroot/pgsql/src/pl/tcl/pltcl.c,v 1.68 2002/12/30 22:10:54 tgl Exp $
34+
* $Header: /cvsroot/pgsql/src/pl/tcl/pltcl.c,v 1.69 2003/02/06 17:02:11 tgl Exp $
3535
*
3636
**********************************************************************/
3737

@@ -1255,7 +1255,7 @@ static int
12551255
pltcl_elog(ClientData cdata, Tcl_Interp *interp,
12561256
int argc, CONST84 char *argv[])
12571257
{
1258-
int level;
1258+
volatile int level;
12591259
sigjmp_buf save_restart;
12601260

12611261
/************************************************************
@@ -1264,18 +1264,6 @@ pltcl_elog(ClientData cdata, Tcl_Interp *interp,
12641264
if (pltcl_restart_in_progress)
12651265
return TCL_ERROR;
12661266

1267-
/************************************************************
1268-
* Catch the restart longjmp and begin a controlled
1269-
* return though all interpreter levels if it happens
1270-
************************************************************/
1271-
memcpy(&save_restart, &Warn_restart, sizeof(save_restart));
1272-
if (sigsetjmp(Warn_restart, 1) != 0)
1273-
{
1274-
memcpy(&Warn_restart, &save_restart, sizeof(Warn_restart));
1275-
pltcl_restart_in_progress = 1;
1276-
return TCL_ERROR;
1277-
}
1278-
12791267
if (argc != 3)
12801268
{
12811269
Tcl_SetResult(interp, "syntax error - 'elog level msg'",
@@ -1301,17 +1289,29 @@ pltcl_elog(ClientData cdata, Tcl_Interp *interp,
13011289
{
13021290
Tcl_AppendResult(interp, "Unknown elog level '", argv[1],
13031291
"'", NULL);
1292+
return TCL_ERROR;
1293+
}
1294+
1295+
/************************************************************
1296+
* Catch the longjmp from elog() and begin a controlled
1297+
* return though all interpreter levels if it happens
1298+
************************************************************/
1299+
memcpy(&save_restart, &Warn_restart, sizeof(save_restart));
1300+
if (sigsetjmp(Warn_restart, 1) != 0)
1301+
{
13041302
memcpy(&Warn_restart, &save_restart, sizeof(Warn_restart));
1303+
pltcl_restart_in_progress = 1;
13051304
return TCL_ERROR;
13061305
}
13071306

13081307
/************************************************************
13091308
* Call elog(), restore the original restart address
1310-
* and return to the caller (if not catched)
1309+
* and return to the caller (if no longjmp)
13111310
************************************************************/
13121311
UTF_BEGIN;
13131312
elog(level, "%s", UTF_U2E(argv[2]));
13141313
UTF_END;
1314+
13151315
memcpy(&Warn_restart, &save_restart, sizeof(Warn_restart));
13161316
return TCL_OK;
13171317
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy