Added some more coverity report patches send in by Martijn van Oosterhout <kleptog...
authorMichael Meskes <[email protected]>
Wed, 21 Jun 2006 11:38:26 +0000 (11:38 +0000)
committerMichael Meskes <[email protected]>
Wed, 21 Jun 2006 11:38:26 +0000 (11:38 +0000)
src/interfaces/ecpg/ecpglib/connect.c
src/interfaces/ecpg/ecpglib/execute.c
src/interfaces/ecpg/ecpglib/misc.c

index 841088f99a2ea925192d48efc0980f7c179e90d8..6dcd5765697ae53163119a6d6cd2badfda166367 100644 (file)
@@ -227,6 +227,9 @@ ECPGnoticeReceiver(void *arg, const PGresult *result)
        if (sqlstate == NULL)
                sqlstate = ECPG_SQLSTATE_ECPG_INTERNAL_ERROR;
 
+       if (message == NULL)  /* Shouldn't happen, but need to be sure */
+               message = "No message received";
+
        /* these are not warnings */
        if (strncmp(sqlstate, "00", 2) == 0)
                return;
index 532b6f1a2c493b3f6627c8826e685d9a7f49eb8c..1bef7225276cb6ba4059123b4250af99d6d9ef1a 100644 (file)
@@ -886,7 +886,6 @@ ECPGstore_input(const int lineno, const bool force_indicator, const struct varia
                                                                PGTYPESnumeric_from_decimal((decimal *) ((var + var->offset * element)->value), nval);
 
                                                        str = PGTYPESnumeric_to_asc(nval, nval->dscale);
-                                                       PGTYPESnumeric_free(nval);
                                                        slen = strlen(str);
 
                                                        if (!(mallocedval = ECPGrealloc(mallocedval, strlen(mallocedval) + slen + sizeof("array [] "), lineno)))
@@ -902,6 +901,7 @@ ECPGstore_input(const int lineno, const bool force_indicator, const struct varia
                                                        strncpy(mallocedval + strlen(mallocedval), str, slen + 1);
                                                        strcpy(mallocedval + strlen(mallocedval), ",");
                                                }
+                                               PGTYPESnumeric_free(nval);
                                                strcpy(mallocedval + strlen(mallocedval) - 1, "]");
                                        }
                                        else
index 810c28af3dae74c099e15c57a153bb15f8bae35d..38f7946984099ca01b5c9ddb7071a6718be18069 100644 (file)
@@ -179,7 +179,7 @@ ECPGtrans(int lineno, const char *connection_name, const char *transaction)
        if (!ECPGinit(con, connection_name, lineno))
                return (false);
 
-       ECPGlog("ECPGtrans line %d action = %s connection = %s\n", lineno, transaction, con->name);
+       ECPGlog("ECPGtrans line %d action = %s connection = %s\n", lineno, transaction, con ? con->name : "(nil)");
 
        /* if we have no connection we just simulate the command */
        if (con && con->connection)