diff options
author | Michael Meskes <meskes@postgresql.org> | 2006-06-26 09:20:09 +0000 |
---|---|---|
committer | Michael Meskes <meskes@postgresql.org> | 2006-06-26 09:20:09 +0000 |
commit | ea9ec780ed6353bb84c48ec49495d29173fd0eb1 (patch) | |
tree | cf2373cd6c9f525b5e26aaaa11c73ed2936ab26e /src/interfaces/ecpg/ecpglib | |
parent | bc28f58b8fe9b25d9b15dd3abc00ea7b72a98909 (diff) | |
download | postgresql-ea9ec780ed6353bb84c48ec49495d29173fd0eb1.tar.gz postgresql-ea9ec780ed6353bb84c48ec49495d29173fd0eb1.zip |
Added some more coverity report patches send in by Joachim Wieland <joe@mcknight.de>.
Diffstat (limited to 'src/interfaces/ecpg/ecpglib')
-rw-r--r-- | src/interfaces/ecpg/ecpglib/execute.c | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/src/interfaces/ecpg/ecpglib/execute.c b/src/interfaces/ecpg/ecpglib/execute.c index 4c43195b942..0ac6b909807 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.49 2006/06/25 09:38:39 meskes Exp $ */ +/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/execute.c,v 1.50 2006/06/26 09:20:09 meskes Exp $ */ /* * The aim is to get a simpler inteface to the database routines. @@ -875,16 +875,16 @@ ECPGstore_input(const int lineno, const bool force_indicator, const struct varia case ECPGt_numeric: { char *str = NULL; - int slen; + int slen; numeric *nval = PGTYPESnumeric_new(); - if (!nval) - return false; - if (var->arrsize > 1) { for (element = 0; element < var->arrsize; element++, nval = PGTYPESnumeric_new()) { + if (!nval) + return false; + if (var->type == ECPGt_numeric) PGTYPESnumeric_copy((numeric *) ((var + var->offset * element)->value), nval); else @@ -892,10 +892,10 @@ ECPGstore_input(const int lineno, const bool force_indicator, const struct varia str = PGTYPESnumeric_to_asc(nval, nval->dscale); slen = strlen(str); + PGTYPESnumeric_free(nval); if (!(mallocedval = ECPGrealloc(mallocedval, strlen(mallocedval) + slen + sizeof("array [] "), lineno))) { - PGTYPESnumeric_free(nval); ECPGfree(str); return false; } @@ -906,24 +906,25 @@ ECPGstore_input(const int lineno, const bool force_indicator, const struct varia strncpy(mallocedval + strlen(mallocedval), str, slen + 1); strcpy(mallocedval + strlen(mallocedval), ","); ECPGfree(str); - PGTYPESnumeric_free(nval); } strcpy(mallocedval + strlen(mallocedval) - 1, "]"); } else { + if (!nval) + return false; + if (var->type == ECPGt_numeric) PGTYPESnumeric_copy((numeric *) (var->value), nval); else PGTYPESnumeric_from_decimal((decimal *) (var->value), nval); str = PGTYPESnumeric_to_asc(nval, nval->dscale); - slen = strlen(str); + PGTYPESnumeric_free(nval); if (!(mallocedval = ECPGalloc(slen + 1, lineno))) { - PGTYPESnumeric_free(nval); free(str); return false; } @@ -931,7 +932,6 @@ ECPGstore_input(const int lineno, const bool force_indicator, const struct varia strncpy(mallocedval, str, slen); mallocedval[slen] = '\0'; ECPGfree(str); - PGTYPESnumeric_free(nval); } *tobeinserted_p = mallocedval; |