1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-18 17:42:25 +03:00

Fixed two more memory leaks in ecpglib.

Synced parser.
This commit is contained in:
Michael Meskes
2006-06-06 11:31:55 +00:00
parent ff0ac57db9
commit 0251602fc9
3 changed files with 140 additions and 75 deletions

View File

@ -1,4 +1,4 @@
/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/data.c,v 1.30 2006/01/17 19:49:23 meskes Exp $ */
/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/data.c,v 1.31 2006/06/06 11:31:55 meskes Exp $ */
#define POSTGRES_ECPG_INTERNAL
#include "postgres_fe.h"
@ -462,7 +462,7 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno,
nres = PGTYPESnumeric_from_asc(pval, &scan_length);
/* did we get an error? */
if (errno != 0)
if (nres == NULL)
{
ECPGlog("ECPGget_data line %d: RESULT: %s errno %d\n", lineno, pval ? pval : "", errno);
@ -487,6 +487,7 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno,
if (garbage_left(isarray, scan_length, compat))
{
free(nres);
ECPGraise(lineno, ECPG_NUMERIC_FORMAT, ECPG_SQLSTATE_DATATYPE_MISMATCH, pval);
return (false);
}
@ -500,6 +501,8 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno,
PGTYPESnumeric_copy(nres, (numeric *) (var + offset * act_tuple));
else
PGTYPESnumeric_to_decimal(nres, (decimal *) (var + offset * act_tuple));
free(nres);
break;
case ECPGt_interval:
@ -511,7 +514,7 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno,
ires = PGTYPESinterval_from_asc(pval, &scan_length);
/* did we get an error? */
if (errno != 0)
if (ires == NULL)
{
if (INFORMIX_MODE(compat))
{
@ -534,6 +537,7 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno,
if (garbage_left(isarray, scan_length, compat))
{
free(ires);
ECPGraise(lineno, ECPG_INTERVAL_FORMAT, ECPG_SQLSTATE_DATATYPE_MISMATCH, pval);
return (false);
}
@ -544,6 +548,7 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno,
ires = PGTYPESinterval_from_asc("0 seconds", NULL);
PGTYPESinterval_copy(ires, (interval *) (var + offset * act_tuple));
free(ires);
break;
case ECPGt_date:
if (pval)