Skip to content

Commit

Permalink
Clean up result if PqSetResultId fails.
Browse files Browse the repository at this point in the history
  • Loading branch information
resuna committed Nov 14, 2017
1 parent 790bce2 commit 5c4caac
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions generic/pgtclCmds.c
Original file line number Diff line number Diff line change
Expand Up @@ -825,8 +825,10 @@ Pg_exec(ClientData cData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])
if (result)
{
int rId;
if(PgSetResultId(interp, connString, result, &rId) != TCL_OK)
if(PgSetResultId(interp, connString, result, &rId) != TCL_OK) {
PQclear(result);
return TCL_ERROR;
}

ExecStatusType rStat = PQresultStatus(result);

Expand Down Expand Up @@ -939,8 +941,10 @@ Pg_exec_prepared(ClientData cData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST
if (result)
{
int rId;
if(PgSetResultId(interp, connString, result, &rId) != TCL_OK)
if(PgSetResultId(interp, connString, result, &rId) != TCL_OK) {
PQclear(result);
return TCL_ERROR;
}

ExecStatusType rStat = PQresultStatus(result);

Expand Down Expand Up @@ -3770,8 +3774,10 @@ Pg_getresult(ClientData cData, Tcl_Interp *interp, int objc,
if (result)
{
int rId;
if(PgSetResultId(interp, connString, result, &rId) != TCL_OK)
if(PgSetResultId(interp, connString, result, &rId) != TCL_OK) {
PQclear(result);
return TCL_ERROR;
}

ExecStatusType rStat = PQresultStatus(result);

Expand Down Expand Up @@ -3846,8 +3852,10 @@ Pg_getdata(ClientData cData, Tcl_Interp *interp, int objc,
if (result)
{
int rId;
if(PgSetResultId(interp, connString, result, &rId) != TCL_OK)
if(PgSetResultId(interp, connString, result, &rId) != TCL_OK) {
PQclear(result);
return TCL_ERROR;
}

ExecStatusType rStat = PQresultStatus(result);

Expand Down Expand Up @@ -5127,8 +5135,10 @@ Pg_sql(ClientData cData, Tcl_Interp *interp, int objc,
if (((result != NULL) || (iResult > 0)) && !callback)
{
int rId;
if(PgSetResultId(interp, connString, result, &rId) != TCL_OK)
if(PgSetResultId(interp, connString, result, &rId) != TCL_OK) {
PQclear(result);
return TCL_ERROR;
}

ExecStatusType rStat = PQresultStatus(result);

Expand Down

0 comments on commit 5c4caac

Please sign in to comment.