Skip to content

Commit 524d65d

Browse files
author
Michael Meskes
committed
Fixed memory leak bugs found by Martijn Oosterhout.
1 parent a16ffee commit 524d65d

File tree

4 files changed

+16
-17
lines changed

4 files changed

+16
-17
lines changed

src/interfaces/ecpg/ChangeLog

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1997,6 +1997,10 @@ Tu Feb 7 18:48:14 CET 2006
19971997
Fri, 17 Mar 2006 16:38:19 +0100
19981998

19991999
- Fixed bug 2330: Wrong error code in case of a duplicate key
2000+
2001+
Mo Apr 24 11:40:05 CEST 2006
2002+
2003+
- Fixed memory leak bugs found by Martijn Oosterhout.
20002004
- Set ecpg library version to 5.2.
20012005
- Set ecpg version to 4.2.1.
20022006

src/interfaces/ecpg/compatlib/informix.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $PostgreSQL: pgsql/src/interfaces/ecpg/compatlib/informix.c,v 1.41 2006/03/11 04:38:39 momjian Exp $ */
1+
/* $PostgreSQL: pgsql/src/interfaces/ecpg/compatlib/informix.c,v 1.42 2006/04/24 09:45:22 meskes Exp $ */
22

33
#include <stdlib.h>
44
#include <string.h>
@@ -166,15 +166,15 @@ ecpg_strndup(const char *str, size_t len)
166166
int
167167
deccvasc(char *cp, int len, decimal *np)
168168
{
169-
char *str = ecpg_strndup(cp, len); /* decimal_in always converts
170-
* the complete string */
171-
int ret = 0;
172-
numeric *result;
169+
char *str;
170+
int ret = 0;
171+
numeric *result;
173172

174173
rsetnull(CDECIMALTYPE, (char *) np);
175174
if (risnull(CSTRINGTYPE, cp))
176175
return 0;
177176

177+
str = ecpg_strndup(cp, len); /* decimal_in always converts the complete string */
178178
if (!str)
179179
ret = ECPG_INFORMIX_NUM_UNDERFLOW;
180180
else

src/interfaces/ecpg/ecpglib/execute.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/execute.c,v 1.44 2005/11/30 12:49:49 meskes Exp $ */
1+
/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/execute.c,v 1.45 2006/04/24 09:45:22 meskes Exp $ */
22

33
/*
44
* The aim is to get a simpler inteface to the database routines.
@@ -860,7 +860,7 @@ ECPGstore_input(const int lineno, const bool force_indicator, const struct varia
860860

861861
if (var->arrsize > 1)
862862
{
863-
for (element = 0; element < var->arrsize; element++)
863+
for (element = 0; element < var->arrsize; element++, nval = PGTYPESnumeric_new())
864864
{
865865
if (var->type == ECPGt_numeric)
866866
PGTYPESnumeric_copy((numeric *) ((var + var->offset * element)->value), nval);

src/interfaces/ecpg/pgtypeslib/numeric.c

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $PostgreSQL: pgsql/src/interfaces/ecpg/pgtypeslib/numeric.c,v 1.25 2006/03/11 04:38:40 momjian Exp $ */
1+
/* $PostgreSQL: pgsql/src/interfaces/ecpg/pgtypeslib/numeric.c,v 1.26 2006/04/24 09:45:22 meskes Exp $ */
22

33
#include "postgres_fe.h"
44
#include <ctype.h>
@@ -364,24 +364,19 @@ PGTYPESnumeric_from_asc(char *str, char **endptr)
364364
numeric *value = (numeric *) pgtypes_alloc(sizeof(numeric));
365365
int ret;
366366

367-
#if 0
368-
long typmod = -1;
369-
#endif
370367
char *realptr;
371368
char **ptr = (endptr != NULL) ? endptr : &realptr;
372369

373-
if (!value)
370+
if (!value)
374371
return (NULL);
375372

376373
ret = set_var_from_str(str, ptr, value);
377374
if (ret)
375+
{
376+
free(value);
378377
return (NULL);
378+
}
379379

380-
#if 0
381-
ret = apply_typmod(value, typmod);
382-
if (ret)
383-
return (NULL);
384-
#endif
385380
return (value);
386381
}
387382

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