1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-05 07:21:24 +03:00

Added fixed from the coverity report send in by Joachim Wieland <joe@mcknight.de>

Added missing error handling in a few functions in ecpglib
This commit is contained in:
Michael Meskes
2006-06-21 10:24:41 +00:00
parent 27c3e3de09
commit a829da152c
12 changed files with 289 additions and 120 deletions

View File

@ -1,4 +1,4 @@
/* $PostgreSQL: pgsql/src/interfaces/ecpg/compatlib/informix.c,v 1.42 2006/04/24 09:45:22 meskes Exp $ */
/* $PostgreSQL: pgsql/src/interfaces/ecpg/compatlib/informix.c,v 1.43 2006/06/21 10:24:40 meskes Exp $ */
#include <stdlib.h>
#include <string.h>
@ -211,13 +211,14 @@ deccvasc(char *cp, int len, decimal *np)
int
deccvdbl(double dbl, decimal *np)
{
numeric *nres = PGTYPESnumeric_new();
numeric *nres;
int result = 1;
rsetnull(CDECIMALTYPE, (char *) np);
if (risnull(CDOUBLETYPE, (char *) &dbl))
return 0;
nres = PGTYPESnumeric_new();
if (nres == NULL)
return ECPG_INFORMIX_OUT_OF_MEMORY;
@ -232,13 +233,14 @@ deccvdbl(double dbl, decimal *np)
int
deccvint(int in, decimal *np)
{
numeric *nres = PGTYPESnumeric_new();
numeric *nres;
int result = 1;
rsetnull(CDECIMALTYPE, (char *) np);
if (risnull(CINTTYPE, (char *) &in))
return 0;
nres = PGTYPESnumeric_new();
if (nres == NULL)
return ECPG_INFORMIX_OUT_OF_MEMORY;
@ -253,13 +255,14 @@ deccvint(int in, decimal *np)
int
deccvlong(long lng, decimal *np)
{
numeric *nres = PGTYPESnumeric_new();
numeric *nres;
int result = 1;
rsetnull(CDECIMALTYPE, (char *) np);
if (risnull(CLONGTYPE, (char *) &lng))
return 0;
nres = PGTYPESnumeric_new();
if (nres == NULL)
return ECPG_INFORMIX_OUT_OF_MEMORY;
@ -342,18 +345,22 @@ int
dectoasc(decimal *np, char *cp, int len, int right)
{
char *str;
numeric *nres = PGTYPESnumeric_new();
if (nres == NULL)
return ECPG_INFORMIX_OUT_OF_MEMORY;
numeric *nres;
rsetnull(CSTRINGTYPE, (char *) cp);
if (risnull(CDECIMALTYPE, (char *) np))
return 0;
if (PGTYPESnumeric_from_decimal(np, nres) != 0)
nres = PGTYPESnumeric_new();
if (nres == NULL)
return ECPG_INFORMIX_OUT_OF_MEMORY;
if (PGTYPESnumeric_from_decimal(np, nres) != 0)
{
PGTYPESnumeric_free(nres);
return ECPG_INFORMIX_OUT_OF_MEMORY;
}
if (right >= 0)
str = PGTYPESnumeric_to_asc(nres, right);
else
@ -376,14 +383,17 @@ dectoasc(decimal *np, char *cp, int len, int right)
int
dectodbl(decimal *np, double *dblp)
{
numeric *nres = PGTYPESnumeric_new();
int i;
numeric *nres = PGTYPESnumeric_new();
if (nres == NULL)
return ECPG_INFORMIX_OUT_OF_MEMORY;
if (PGTYPESnumeric_from_decimal(np, nres) != 0)
{
PGTYPESnumeric_free(nres);
return ECPG_INFORMIX_OUT_OF_MEMORY;
}
i = PGTYPESnumeric_to_double(nres, dblp);
PGTYPESnumeric_free(nres);
@ -401,7 +411,10 @@ dectoint(decimal *np, int *ip)
return ECPG_INFORMIX_OUT_OF_MEMORY;
if (PGTYPESnumeric_from_decimal(np, nres) != 0)
{
PGTYPESnumeric_free(nres);
return ECPG_INFORMIX_OUT_OF_MEMORY;
}
ret = PGTYPESnumeric_to_int(nres, ip);
@ -415,15 +428,19 @@ int
dectolong(decimal *np, long *lngp)
{
int ret;
numeric *nres = PGTYPESnumeric_new();;
numeric *nres = PGTYPESnumeric_new();
if (nres == NULL)
return ECPG_INFORMIX_OUT_OF_MEMORY;
if (PGTYPESnumeric_from_decimal(np, nres) != 0)
{
PGTYPESnumeric_free(nres);
return ECPG_INFORMIX_OUT_OF_MEMORY;
}
ret = PGTYPESnumeric_to_long(nres, lngp);
PGTYPESnumeric_free(nres);
if (ret == PGTYPES_NUM_OVERFLOW)
ret = ECPG_INFORMIX_NUM_OVERFLOW;