diff options
author | Michael Meskes <meskes@postgresql.org> | 2006-07-05 10:50:06 +0000 |
---|---|---|
committer | Michael Meskes <meskes@postgresql.org> | 2006-07-05 10:50:06 +0000 |
commit | bf1cd364b6de8af7e727ea7832be17d32f4cca89 (patch) | |
tree | f93a808c100e272195a079594f726c4c2a0b2b4e /src/interfaces/ecpg/ecpglib/execute.c | |
parent | 8728d4aba91a5621bb4eb869d2f1050d63de3b9d (diff) | |
download | postgresql-bf1cd364b6de8af7e727ea7832be17d32f4cca89.tar.gz postgresql-bf1cd364b6de8af7e727ea7832be17d32f4cca89.zip |
Fixed remaining Coverity bugs.
Diffstat (limited to 'src/interfaces/ecpg/ecpglib/execute.c')
-rw-r--r-- | src/interfaces/ecpg/ecpglib/execute.c | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/src/interfaces/ecpg/ecpglib/execute.c b/src/interfaces/ecpg/ecpglib/execute.c index f8d348d0a86..704e5c2ed02 100644 --- a/src/interfaces/ecpg/ecpglib/execute.c +++ b/src/interfaces/ecpg/ecpglib/execute.c @@ -1,4 +1,4 @@ -/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/execute.c,v 1.43.2.6 2006/06/26 09:20:19 meskes Exp $ */ +/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/execute.c,v 1.43.2.7 2006/07/05 10:50:06 meskes Exp $ */ /* * The aim is to get a simpler inteface to the database routines. @@ -871,12 +871,13 @@ ECPGstore_input(const int lineno, const bool force_indicator, const struct varia { char *str = NULL; int slen; - numeric *nval = PGTYPESnumeric_new(); + numeric *nval; if (var->arrsize > 1) { - for (element = 0; element < var->arrsize; element++, nval = PGTYPESnumeric_new()) + for (element = 0; element < var->arrsize; element++) { + nval = PGTYPESnumeric_new(); if (!nval) return false; @@ -906,6 +907,7 @@ ECPGstore_input(const int lineno, const bool force_indicator, const struct varia } else { + nval = PGTYPESnumeric_new(); if (!nval) return false; @@ -1043,16 +1045,22 @@ ECPGstore_input(const int lineno, const bool force_indicator, const struct varia case ECPGt_timestamp: { - char *str = NULL; + char *str = NULL, *asc = NULL; int slen; if (var->arrsize > 1) { for (element = 0; element < var->arrsize; element++) { - str = quote_postgres(PGTYPEStimestamp_to_asc(*(timestamp *) ((var + var->offset * element)->value)), lineno); + asc = PGTYPEStimestamp_to_asc(*(timestamp *) ((var + var->offset * element)->value)); + if (!asc) + return false; + + str = quote_postgres(asc, lineno); + ECPGfree(asc); /* we don't need this anymore so free it asap. */ if (!str) return false; + slen = strlen(str); if (!(mallocedval = ECPGrealloc(mallocedval, strlen(mallocedval) + slen + sizeof("array [], timestamp "), lineno))) @@ -1072,7 +1080,12 @@ ECPGstore_input(const int lineno, const bool force_indicator, const struct varia } else { - str = quote_postgres(PGTYPEStimestamp_to_asc(*(timestamp *) (var->value)), lineno); + asc = PGTYPEStimestamp_to_asc(*(timestamp *) (var->value)); + if (!asc) + return false; + + str = quote_postgres(asc, lineno); + ECPGfree(asc); /* we don't need this anymore so free it asap. */ if (!str) return false; slen = strlen(str); |