Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit61fb800

Browse files
committed
Fix volatile-safety issue in pltcl_SPI_execute_plan().
The "callargs" variable is modified within PG_TRY and then referencedwithin PG_CATCH, which is exactly the coding pattern we've now foundto be unsafe. Marking "callargs" volatile would be problematic becauseit is passed by reference to some Tcl functions, so fix the problemby not modifying it within PG_TRY. We can just postpone the free()till we exit the PG_TRY construct, as is already done elsewhere in thissame file.Also, fix failure to free(callargs) when exiting on too-many-argumentserror. This is only a minor memory leak, but a leak nonetheless.In passing, remove some unnecessary "volatile" markings in the samefunction. Those doubtless are there because gcc 2.95.3 whinged aboutthem, but we now know that its algorithm for complaining is many bricksshy of a load.This is certainly a live bug with compilers that optimize similarlyto current gcc, so back-patch to all active branches.
1 parent03a37e9 commit61fb800

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

‎src/pl/tcl/pltcl.c

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2165,9 +2165,9 @@ pltcl_SPI_execute_plan(ClientData cdata, Tcl_Interp *interp,
21652165
intj;
21662166
Tcl_HashEntry*hashent;
21672167
pltcl_query_desc*qdesc;
2168-
constchar*volatilenulls=NULL;
2169-
CONST84char*volatilearrayname=NULL;
2170-
CONST84char*volatileloop_body=NULL;
2168+
constchar*nulls=NULL;
2169+
CONST84char*arrayname=NULL;
2170+
CONST84char*loop_body=NULL;
21712171
intcount=0;
21722172
intcallnargs;
21732173
CONST84char**callargs=NULL;
@@ -2297,6 +2297,8 @@ pltcl_SPI_execute_plan(ClientData cdata, Tcl_Interp *interp,
22972297
if (i!=argc)
22982298
{
22992299
Tcl_SetResult(interp,usage,TCL_STATIC);
2300+
if (callargs)
2301+
ckfree((char*)callargs);
23002302
returnTCL_ERROR;
23012303
}
23022304

@@ -2335,10 +2337,6 @@ pltcl_SPI_execute_plan(ClientData cdata, Tcl_Interp *interp,
23352337
}
23362338
}
23372339

2338-
if (callargs)
2339-
ckfree((char*)callargs);
2340-
callargs=NULL;
2341-
23422340
/************************************************************
23432341
* Execute the plan
23442342
************************************************************/
@@ -2365,6 +2363,9 @@ pltcl_SPI_execute_plan(ClientData cdata, Tcl_Interp *interp,
23652363
}
23662364
PG_END_TRY();
23672365

2366+
if (callargs)
2367+
ckfree((char*)callargs);
2368+
23682369
returnmy_rc;
23692370
}
23702371

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp