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

Commit78bfc22

Browse files
committed
Fix use-after-free error reported by Neil Conway.
1 parent569e32a commit78bfc22

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

‎src/bin/psql/common.c

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* Copyright (c) 2000-2006, PostgreSQL Global Development Group
55
*
6-
* $PostgreSQL: pgsql/src/bin/psql/common.c,v 1.119 2006/06/14 16:49:02 tgl Exp $
6+
* $PostgreSQL: pgsql/src/bin/psql/common.c,v 1.120 2006/06/30 15:06:05 alvherre Exp $
77
*/
88
#include"postgres_fe.h"
99
#include"common.h"
@@ -875,19 +875,19 @@ SendQuery(const char *query)
875875
if (OK)
876876
OK=PrintQueryResults(results);
877877

878-
PQclear(results);
879-
880878
/* If we made a temporary savepoint, possibly release/rollback */
881879
if (on_error_rollback_savepoint)
882880
{
881+
PGresult*svptres;
882+
883883
transaction_status=PQtransactionStatus(pset.db);
884884

885885
/* We always rollback on an error */
886886
if (transaction_status==PQTRANS_INERROR)
887-
results=PQexec(pset.db,"ROLLBACK TO pg_psql_temporary_savepoint");
887+
svptres=PQexec(pset.db,"ROLLBACK TO pg_psql_temporary_savepoint");
888888
/* If they are no longer in a transaction, then do nothing */
889889
elseif (transaction_status!=PQTRANS_INTRANS)
890-
results=NULL;
890+
svptres=NULL;
891891
else
892892
{
893893
/*
@@ -898,20 +898,22 @@ SendQuery(const char *query)
898898
if (strcmp(PQcmdStatus(results),"SAVEPOINT")==0||
899899
strcmp(PQcmdStatus(results),"RELEASE")==0||
900900
strcmp(PQcmdStatus(results),"ROLLBACK")==0)
901-
results=NULL;
901+
svptres=NULL;
902902
else
903-
results=PQexec(pset.db,"RELEASE pg_psql_temporary_savepoint");
903+
svptres=PQexec(pset.db,"RELEASE pg_psql_temporary_savepoint");
904904
}
905-
if (PQresultStatus(results)!=PGRES_COMMAND_OK)
905+
if (svptres&&PQresultStatus(svptres)!=PGRES_COMMAND_OK)
906906
{
907907
psql_error("%s",PQerrorMessage(pset.db));
908908
PQclear(results);
909+
PQclear(svptres);
909910
ResetCancelConn();
910911
return false;
911912
}
912-
PQclear(results);
913913
}
914914

915+
PQclear(results);
916+
915917
/* Possible microtiming output */
916918
if (OK&&pset.timing)
917919
printf(_("Time: %.3f ms\n"),DIFF_MSEC(&after,&before));

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp