Skip to content

Commit ea9ec78

Browse files
author
Michael Meskes
committed
Added some more coverity report patches send in by Joachim Wieland <joe@mcknight.de>.
1 parent bc28f58 commit ea9ec78

File tree

3 files changed

+17
-11
lines changed

3 files changed

+17
-11
lines changed

src/interfaces/ecpg/ChangeLog

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2030,5 +2030,10 @@ we Jun 21 13:37:00 CEST 2006
20302030
Su Jun 25 11:27:46 CEST 2006
20312031

20322032
- Moved some free() calls that coverity correctly complains about.
2033+
2034+
Mo Jun 26 11:05:25 CEST 2006
2035+
2036+
- Added some more coverity report patches send in by Joachim Wieland
2037+
<joe@mcknight.de>.
20332038
- Set ecpg library version to 5.2.
20342039
- Set ecpg version to 4.2.1.

src/interfaces/ecpg/compatlib/informix.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/compatlib/informix.c,v 1.45 2006/06/25 01:45:32 momjian Exp $ */
1+
/* $PostgreSQL: pgsql/src/interfaces/ecpg/compatlib/informix.c,v 1.46 2006/06/26 09:20:09 meskes Exp $ */
22

33
#include <stdlib.h>
44
#include <string.h>
@@ -417,6 +417,7 @@ dectoint(decimal *np, int *ip)
417417
}
418418

419419
ret = PGTYPESnumeric_to_int(nres, ip);
420+
PGTYPESnumeric_free(nres);
420421

421422
if (ret == PGTYPES_NUM_OVERFLOW)
422423
ret = ECPG_INFORMIX_NUM_OVERFLOW;

src/interfaces/ecpg/ecpglib/execute.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/execute.c,v 1.49 2006/06/25 09:38:39 meskes Exp $ */
1+
/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/execute.c,v 1.50 2006/06/26 09:20:09 meskes Exp $ */
22

33
/*
44
* The aim is to get a simpler inteface to the database routines.
@@ -875,27 +875,27 @@ ECPGstore_input(const int lineno, const bool force_indicator, const struct varia
875875
case ECPGt_numeric:
876876
{
877877
char *str = NULL;
878-
int slen;
878+
int slen;
879879
numeric *nval = PGTYPESnumeric_new();
880880

881-
if (!nval)
882-
return false;
883-
884881
if (var->arrsize > 1)
885882
{
886883
for (element = 0; element < var->arrsize; element++, nval = PGTYPESnumeric_new())
887884
{
885+
if (!nval)
886+
return false;
887+
888888
if (var->type == ECPGt_numeric)
889889
PGTYPESnumeric_copy((numeric *) ((var + var->offset * element)->value), nval);
890890
else
891891
PGTYPESnumeric_from_decimal((decimal *) ((var + var->offset * element)->value), nval);
892892

893893
str = PGTYPESnumeric_to_asc(nval, nval->dscale);
894894
slen = strlen(str);
895+
PGTYPESnumeric_free(nval);
895896

896897
if (!(mallocedval = ECPGrealloc(mallocedval, strlen(mallocedval) + slen + sizeof("array [] "), lineno)))
897898
{
898-
PGTYPESnumeric_free(nval);
899899
ECPGfree(str);
900900
return false;
901901
}
@@ -906,32 +906,32 @@ ECPGstore_input(const int lineno, const bool force_indicator, const struct varia
906906
strncpy(mallocedval + strlen(mallocedval), str, slen + 1);
907907
strcpy(mallocedval + strlen(mallocedval), ",");
908908
ECPGfree(str);
909-
PGTYPESnumeric_free(nval);
910909
}
911910
strcpy(mallocedval + strlen(mallocedval) - 1, "]");
912911
}
913912
else
914913
{
914+
if (!nval)
915+
return false;
916+
915917
if (var->type == ECPGt_numeric)
916918
PGTYPESnumeric_copy((numeric *) (var->value), nval);
917919
else
918920
PGTYPESnumeric_from_decimal((decimal *) (var->value), nval);
919921

920922
str = PGTYPESnumeric_to_asc(nval, nval->dscale);
921-
922923
slen = strlen(str);
924+
PGTYPESnumeric_free(nval);
923925

924926
if (!(mallocedval = ECPGalloc(slen + 1, lineno)))
925927
{
926-
PGTYPESnumeric_free(nval);
927928
free(str);
928929
return false;
929930
}
930931

931932
strncpy(mallocedval, str, slen);
932933
mallocedval[slen] = '\0';
933934
ECPGfree(str);
934-
PGTYPESnumeric_free(nval);
935935
}
936936

937937
*tobeinserted_p = mallocedval;

0 commit comments

Comments
 (0)