From: Michael Meskes Date: Fri, 8 Jan 2010 09:22:44 +0000 (+0000) Subject: Backported fix for protecting ecpg against applications freeing strings to 8.4. X-Git-Tag: REL8_4_3~72 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6e417452e354272372340687bcc54ca4d99854e5;p=thirdparty%2Fpostgresql.git Backported fix for protecting ecpg against applications freeing strings to 8.4. --- diff --git a/src/interfaces/ecpg/ecpglib/prepare.c b/src/interfaces/ecpg/ecpglib/prepare.c index e60363d6fe8..fa8078fbb26 100644 --- a/src/interfaces/ecpg/ecpglib/prepare.c +++ b/src/interfaces/ecpg/ecpglib/prepare.c @@ -1,4 +1,4 @@ -/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/prepare.c,v 1.31.2.1 2009/07/22 11:07:04 mha Exp $ */ +/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/prepare.c,v 1.31.2.2 2010/01/08 09:22:44 meskes Exp $ */ #define POSTGRES_ECPG_INTERNAL #include "postgres_fe.h" @@ -152,7 +152,7 @@ ECPGprepare(int lineno, const char *connection_name, const bool questionmarks, c replace_variables(&(stmt->command), lineno); /* add prepared statement to our list */ - this->name = (char *) name; + this->name = ecpg_strdup(name, lineno); this->stmt = stmt; /* and finally really prepare the statement */ @@ -160,6 +160,7 @@ ECPGprepare(int lineno, const char *connection_name, const bool questionmarks, c if (!ecpg_check_PQresult(query, stmt->lineno, stmt->connection->connection, stmt->compat)) { ecpg_free(stmt->command); + ecpg_free(this->name); ecpg_free(this); ecpg_free(stmt); return false; @@ -238,6 +239,7 @@ deallocate_one(int lineno, enum COMPAT_MODE c, struct connection * con, struct p /* okay, free all the resources */ ecpg_free(this->stmt->command); ecpg_free(this->stmt); + ecpg_free(this->name); if (prev != NULL) prev->next = this->next; else