mirror of
https://github.com/postgres/postgres.git
synced 2025-06-06 00:02:36 -04:00
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
This commit is contained in:
parent
7431796b46
commit
9805abb0fb
@ -528,13 +528,13 @@ ECPGexecute(struct statement * stmt)
|
|||||||
{
|
{
|
||||||
int slen = strlen((char *) var->value);
|
int slen = strlen((char *) var->value);
|
||||||
|
|
||||||
if (!(newcopy = ecpg_alloc(slen + 1, stmt->lineno)))
|
if (!(mallocedval = ecpg_alloc(slen + 1, stmt->lineno)))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
strncpy(newcopy, (char *) var->value, slen);
|
strncpy(mallocedval, (char *) var->value, slen);
|
||||||
newcopy[slen] = '\0';
|
mallocedval[slen] = '\0';
|
||||||
|
|
||||||
tobeinserted = newcopy;
|
tobeinserted = mallocedval;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case ECPGt_varchar:
|
case ECPGt_varchar:
|
||||||
@ -1132,13 +1132,13 @@ ECPGtrans(int lineno, const char *connection_name, const char *transaction)
|
|||||||
con->committed = true;
|
con->committed = true;
|
||||||
|
|
||||||
/* deallocate all prepared statements */
|
/* deallocate all prepared statements */
|
||||||
for (this = prep_stmts; this != NULL; this = this->next)
|
while(prep_stmts != NULL) {
|
||||||
{
|
bool b = ECPGdeallocate(lineno, prep_stmts->name);
|
||||||
bool b = ECPGdeallocate(lineno, this->name);
|
|
||||||
|
|
||||||
if (!b)
|
if (!b)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -1416,6 +1416,7 @@ ECPGdeallocate(int lineno, char *name)
|
|||||||
else
|
else
|
||||||
prep_stmts = this->next;
|
prep_stmts = this->next;
|
||||||
|
|
||||||
|
free(this);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
ECPGlog("deallocate_prepare: invalid statement name %s\n", name);
|
ECPGlog("deallocate_prepare: invalid statement name %s\n", name);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user