Skip to content

Commit 9805abb

Browse files
committed
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
1 parent 7431796 commit 9805abb

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

src/interfaces/ecpg/lib/ecpglib.c

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -528,13 +528,13 @@ ECPGexecute(struct statement * stmt)
528528
{
529529
int slen = strlen((char *) var->value);
530530

531-
if (!(newcopy = ecpg_alloc(slen + 1, stmt->lineno)))
531+
if (!(mallocedval = ecpg_alloc(slen + 1, stmt->lineno)))
532532
return false;
533533

534-
strncpy(newcopy, (char *) var->value, slen);
535-
newcopy[slen] = '\0';
534+
strncpy(mallocedval, (char *) var->value, slen);
535+
mallocedval[slen] = '\0';
536536

537-
tobeinserted = newcopy;
537+
tobeinserted = mallocedval;
538538
}
539539
break;
540540
case ECPGt_varchar:
@@ -1132,13 +1132,13 @@ ECPGtrans(int lineno, const char *connection_name, const char *transaction)
11321132
con->committed = true;
11331133

11341134
/* deallocate all prepared statements */
1135-
for (this = prep_stmts; this != NULL; this = this->next)
1136-
{
1137-
bool b = ECPGdeallocate(lineno, this->name);
1135+
while(prep_stmts != NULL) {
1136+
bool b = ECPGdeallocate(lineno, prep_stmts->name);
11381137

11391138
if (!b)
11401139
return false;
11411140
}
1141+
11421142
}
11431143

11441144
return true;
@@ -1416,6 +1416,7 @@ ECPGdeallocate(int lineno, char *name)
14161416
else
14171417
prep_stmts = this->next;
14181418

1419+
free(this);
14191420
return true;
14201421
}
14211422
ECPGlog("deallocate_prepare: invalid statement name %s\n", name);

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy