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

index cf5b9c6edb599244b1865dd2990101ca3b1d8cbd..9b6964a31b9cd7a5774a53afae0996cc7d73f1dd 100644 (file)
@@ -222,6 +222,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 ee05488765b8f62022fe1eff6fff99e801ac3009..0705dd4b4433a9dc41a360c7044661499dc06e23 100644 (file)
@@ -895,7 +895,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)))
@@ -911,6 +910,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 7dca76819cfe8ea942e3fc57e9a959adf53def2b..efafbf055f60ded0cb93f94a5fc143fe22ad790a 100644 (file)
@@ -181,7 +181,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)