Skip to content

Commit 0251602

Browse files
author
Michael Meskes
committed
Fixed two more memory leaks in ecpglib.
Synced parser.
1 parent ff0ac57 commit 0251602

File tree

3 files changed

+140
-75
lines changed

3 files changed

+140
-75
lines changed

src/interfaces/ecpg/ecpglib/data.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/data.c,v 1.30 2006/01/17 19:49:23 meskes Exp $ */
1+
/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/data.c,v 1.31 2006/06/06 11:31:55 meskes Exp $ */
22

33
#define POSTGRES_ECPG_INTERNAL
44
#include "postgres_fe.h"
@@ -462,7 +462,7 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno,
462462
nres = PGTYPESnumeric_from_asc(pval, &scan_length);
463463

464464
/* did we get an error? */
465-
if (errno != 0)
465+
if (nres == NULL)
466466
{
467467
ECPGlog("ECPGget_data line %d: RESULT: %s errno %d\n", lineno, pval ? pval : "", errno);
468468

@@ -487,6 +487,7 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno,
487487

488488
if (garbage_left(isarray, scan_length, compat))
489489
{
490+
free(nres);
490491
ECPGraise(lineno, ECPG_NUMERIC_FORMAT, ECPG_SQLSTATE_DATATYPE_MISMATCH, pval);
491492
return (false);
492493
}
@@ -500,6 +501,8 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno,
500501
PGTYPESnumeric_copy(nres, (numeric *) (var + offset * act_tuple));
501502
else
502503
PGTYPESnumeric_to_decimal(nres, (decimal *) (var + offset * act_tuple));
504+
505+
free(nres);
503506
break;
504507

505508
case ECPGt_interval:
@@ -511,7 +514,7 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno,
511514
ires = PGTYPESinterval_from_asc(pval, &scan_length);
512515

513516
/* did we get an error? */
514-
if (errno != 0)
517+
if (ires == NULL)
515518
{
516519
if (INFORMIX_MODE(compat))
517520
{
@@ -534,6 +537,7 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno,
534537

535538
if (garbage_left(isarray, scan_length, compat))
536539
{
540+
free(ires);
537541
ECPGraise(lineno, ECPG_INTERVAL_FORMAT, ECPG_SQLSTATE_DATATYPE_MISMATCH, pval);
538542
return (false);
539543
}
@@ -544,6 +548,7 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno,
544548
ires = PGTYPESinterval_from_asc("0 seconds", NULL);
545549

546550
PGTYPESinterval_copy(ires, (interval *) (var + offset * act_tuple));
551+
free(ires);
547552
break;
548553
case ECPGt_date:
549554
if (pval)

src/interfaces/ecpg/pgtypeslib/interval.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $PostgreSQL: pgsql/src/interfaces/ecpg/pgtypeslib/interval.c,v 1.31 2006/03/11 04:38:39 momjian Exp $ */
1+
/* $PostgreSQL: pgsql/src/interfaces/ecpg/pgtypeslib/interval.c,v 1.32 2006/06/06 11:31:55 meskes Exp $ */
22

33
#include "postgres_fe.h"
44
#include <time.h>
@@ -793,6 +793,7 @@ PGTYPESinterval_from_asc(char *str, char **endptr)
793793
return NULL;
794794
}
795795

796+
errno = 0;
796797
return result;
797798
}
798799

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