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

Commit39fe881

Browse files
committed
Fix more thinkos in new ECPG "PREPARE AS" code.
ecpg_build_params() failed to check for ecpg_alloc failure in onenewly-added code path, and leaked a temporary string in another path.Errors in commita1dc6ab, spotted by Coverity.
1 parent331695a commit39fe881

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

‎src/interfaces/ecpg/ecpglib/execute.c‎

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1454,13 +1454,21 @@ ecpg_build_params(struct statement *stmt)
14541454
if (stmt->statement_type==ECPGst_prepare||
14551455
stmt->statement_type==ECPGst_exec_with_exprlist)
14561456
{
1457-
/* Add double quote both side for embedding statement name. */
1458-
char*str=ecpg_alloc(strlen(tobeinserted)+2+1,stmt->lineno);
1457+
/* Need to double-quote the inserted statement name. */
1458+
char*str=ecpg_alloc(strlen(tobeinserted)+2+1,
1459+
stmt->lineno);
14591460

1461+
if (!str)
1462+
{
1463+
ecpg_free(tobeinserted);
1464+
ecpg_free_params(stmt, false);
1465+
return false;
1466+
}
14601467
sprintf(str,"\"%s\"",tobeinserted);
14611468
ecpg_free(tobeinserted);
14621469
tobeinserted=str;
14631470
}
1471+
14641472
if (!insert_tobeinserted(position,2,stmt,tobeinserted))
14651473
{
14661474
ecpg_free_params(stmt, false);
@@ -1470,11 +1478,13 @@ ecpg_build_params(struct statement *stmt)
14701478
}
14711479
elseif (stmt->statement_type==ECPGst_exec_with_exprlist)
14721480
{
1473-
14741481
if (binary_format)
14751482
{
1476-
char*p=convert_bytea_to_string(tobeinserted,binary_length,stmt->lineno);
1483+
char*p=convert_bytea_to_string(tobeinserted,
1484+
binary_length,
1485+
stmt->lineno);
14771486

1487+
ecpg_free(tobeinserted);
14781488
if (!p)
14791489
{
14801490
ecpg_free_params(stmt, false);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp