aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruce Momjian <bruce@momjian.us>1999-12-14 22:03:48 +0000
committerBruce Momjian <bruce@momjian.us>1999-12-14 22:03:48 +0000
commit9805abb0fb1d2d57834a233d1a34279757d3f068 (patch)
tree063111929cf136d5d85a0e520641bc107c88f877
parent7431796b46e53da3d548e82928c1a18c08e936c9 (diff)
downloadpostgresql-9805abb0fb1d2d57834a233d1a34279757d3f068.tar.gz
postgresql-9805abb0fb1d2d57834a233d1a34279757d3f068.zip
This patch solves a couple of memory leaks in ecpglib.c. The patch is
ok for both the development tree (CVS) and for 6.5.3. Stephen Birch
-rw-r--r--src/interfaces/ecpg/lib/ecpglib.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/src/interfaces/ecpg/lib/ecpglib.c b/src/interfaces/ecpg/lib/ecpglib.c
index 2cb0e105479..3d6fd056230 100644
--- a/src/interfaces/ecpg/lib/ecpglib.c
+++ b/src/interfaces/ecpg/lib/ecpglib.c
@@ -528,13 +528,13 @@ ECPGexecute(struct statement * stmt)
{
int slen = strlen((char *) var->value);
- if (!(newcopy = ecpg_alloc(slen + 1, stmt->lineno)))
+ if (!(mallocedval = ecpg_alloc(slen + 1, stmt->lineno)))
return false;
- strncpy(newcopy, (char *) var->value, slen);
- newcopy[slen] = '\0';
+ strncpy(mallocedval, (char *) var->value, slen);
+ mallocedval[slen] = '\0';
- tobeinserted = newcopy;
+ tobeinserted = mallocedval;
}
break;
case ECPGt_varchar:
@@ -1132,13 +1132,13 @@ ECPGtrans(int lineno, const char *connection_name, const char *transaction)
con->committed = true;
/* deallocate all prepared statements */
- for (this = prep_stmts; this != NULL; this = this->next)
- {
- bool b = ECPGdeallocate(lineno, this->name);
+ while(prep_stmts != NULL) {
+ bool b = ECPGdeallocate(lineno, prep_stmts->name);
if (!b)
return false;
}
+
}
return true;
@@ -1416,6 +1416,7 @@ ECPGdeallocate(int lineno, char *name)
else
prep_stmts = this->next;
+ free(this);
return true;
}
ECPGlog("deallocate_prepare: invalid statement name %s\n", name);