Subject: | dbdimp.c: fixed some memory leaks |
Here is the patch that fixes 3 similar memory leaks.
--
Alexey Tourbin
ALT Linux Team
Subject: | DBD-Pg-2.2.0-action-leaks.patch |
diff --git a/dbdimp.c b/dbdimp.c
index 228c8ec..f9ee3f4 100644
--- a/dbdimp.c
+++ b/dbdimp.c
@@ -3825,13 +3825,9 @@ int pg_db_savepoint (SV * dbh, imp_dbh_t * imp_dbh, char * savepoint)
if (TSTART) TRC(DBILOGFP, "%sBegin pg_db_savepoint (name: %s)\n", THEADER, savepoint);
- New(0, action, strlen(savepoint) + 11, char); /* freed below */
-
if (imp_dbh->pg_server_version < 80000)
croak("Savepoints are only supported on server version 8.0 or higher");
- sprintf(action, "savepoint %s", savepoint);
-
/* no action if AutoCommit = on or the connection is invalid */
if ((NULL == imp_dbh->conn) || (DBIc_has(imp_dbh, DBIcf_AutoCommit))) {
if (TEND) TRC(DBILOGFP, "%sEnd pg_db_savepoint (0)\n", THEADER);
@@ -3850,6 +3846,8 @@ int pg_db_savepoint (SV * dbh, imp_dbh_t * imp_dbh, char * savepoint)
imp_dbh->done_begin = DBDPG_TRUE;
}
+ New(0, action, strlen(savepoint) + 11, char); /* freed below */
+ sprintf(action, "savepoint %s", savepoint);
status = _result(aTHX_ imp_dbh, action);
Safefree(action);
@@ -3876,19 +3874,17 @@ int pg_db_rollback_to (SV * dbh, imp_dbh_t * imp_dbh, const char *savepoint)
if (TSTART) TRC(DBILOGFP, "%sBegin pg_db_rollback_to (name: %s)\n", THEADER, savepoint);
- New(0, action, strlen(savepoint) + 13, char);
-
if (imp_dbh->pg_server_version < 80000)
croak("Savepoints are only supported on server version 8.0 or higher");
- sprintf(action, "rollback to %s", savepoint);
-
/* no action if AutoCommit = on or the connection is invalid */
if ((NULL == imp_dbh->conn) || (DBIc_has(imp_dbh, DBIcf_AutoCommit))) {
if (TEND) TRC(DBILOGFP, "%sEnd pg_db_rollback_to (0)\n", THEADER);
return 0;
}
+ New(0, action, strlen(savepoint) + 13, char);
+ sprintf(action, "rollback to %s", savepoint);
status = _result(aTHX_ imp_dbh, action);
Safefree(action);
@@ -3915,19 +3911,17 @@ int pg_db_release (SV * dbh, imp_dbh_t * imp_dbh, char * savepoint)
if (TSTART) TRC(DBILOGFP, "%sBegin pg_db_release (name: %s)\n", THEADER, savepoint);
- New(0, action, strlen(savepoint) + 9, char);
-
if (imp_dbh->pg_server_version < 80000)
croak("Savepoints are only supported on server version 8.0 or higher");
- sprintf(action, "release %s", savepoint);
-
/* no action if AutoCommit = on or the connection is invalid */
if ((NULL == imp_dbh->conn) || (DBIc_has(imp_dbh, DBIcf_AutoCommit))) {
if (TEND) TRC(DBILOGFP, "%sEnd pg_db_release (0)\n", THEADER);
return 0;
}
+ New(0, action, strlen(savepoint) + 9, char);
+ sprintf(action, "release %s", savepoint);
status = _result(aTHX_ imp_dbh, action);
Safefree(action);