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

Commitf7332e8

Browse files
committed
Remove duplicate PQclear(res) operations leading to double free() and
subsequent core dump. It looks like at one time DBLINK_RES_ERROR_AS_NOTICEdidn't include a PQclear, but now it does and so these other ones areduplicate.
1 parent1ad6878 commitf7332e8

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

‎contrib/dblink/dblink.c

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,6 @@ dblink_open(PG_FUNCTION_ARGS)
345345
else
346346
{
347347
DBLINK_RES_ERROR_AS_NOTICE("sql error");
348-
PQclear(res);
349348
PG_RETURN_TEXT_P(GET_TEXT("ERROR"));
350349
}
351350
}
@@ -419,7 +418,6 @@ dblink_close(PG_FUNCTION_ARGS)
419418
else
420419
{
421420
DBLINK_RES_ERROR_AS_NOTICE("sql error");
422-
PQclear(res);
423421
PG_RETURN_TEXT_P(GET_TEXT("ERROR"));
424422
}
425423
}
@@ -531,8 +529,6 @@ dblink_fetch(PG_FUNCTION_ARGS)
531529
DBLINK_RES_ERROR("sql error");
532530
else
533531
{
534-
if (res)
535-
PQclear(res);
536532
DBLINK_RES_ERROR_AS_NOTICE("sql error");
537533
SRF_RETURN_DONE(funcctx);
538534
}
@@ -720,11 +716,9 @@ dblink_record(PG_FUNCTION_ARGS)
720716
DBLINK_RES_ERROR("sql error");
721717
else
722718
{
723-
if (res)
724-
PQclear(res);
719+
DBLINK_RES_ERROR_AS_NOTICE("sql error");
725720
if (freeconn)
726721
PQfinish(conn);
727-
DBLINK_RES_ERROR_AS_NOTICE("sql error");
728722
SRF_RETURN_DONE(funcctx);
729723
}
730724
}
@@ -938,13 +932,15 @@ dblink_exec(PG_FUNCTION_ARGS)
938932
* result tuple
939933
*/
940934
sql_cmd_status=GET_TEXT(PQcmdStatus(res));
935+
PQclear(res);
941936
}
942937
else
938+
{
939+
PQclear(res);
943940
ereport(ERROR,
944941
(errcode(ERRCODE_S_R_E_PROHIBITED_SQL_STATEMENT_ATTEMPTED),
945942
errmsg("statement returning results not allowed")));
946-
947-
PQclear(res);
943+
}
948944

949945
/* if needed, close the connection to the database and cleanup */
950946
if (freeconn)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp