]> granicus.if.org Git - postgresql/commitdiff
Added some more coverity report patches send in by Martijn van Oosterhout <kleptog...
authorMichael Meskes <meskes@postgresql.org>
Wed, 21 Jun 2006 11:38:26 +0000 (11:38 +0000)
committerMichael Meskes <meskes@postgresql.org>
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 91f09e1e2ff251963ba2b8a31ca94599ecc1f6bf..6f3a8ed10b8dacecab8c41fe8283b2b103a47e1a 100644 (file)
@@ -1,4 +1,4 @@
-/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/connect.c,v 1.26.2.3 2006/06/21 10:29:50 meskes Exp $ */
+/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/connect.c,v 1.26.2.4 2006/06/21 11:38:26 meskes Exp $ */
 
 #define POSTGRES_ECPG_INTERNAL
 #include "postgres_fe.h"
@@ -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 34050bd79547c56a4673e6bcc35111f0ffe406f2..7e788d1115892d2606213f6c09fc179409541c77 100644 (file)
@@ -1,4 +1,4 @@
-/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/execute.c,v 1.43.2.3 2006/06/21 10:29:50 meskes Exp $ */
+/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/execute.c,v 1.43.2.4 2006/06/21 11:38:26 meskes Exp $ */
 
 /*
  * The aim is to get a simpler inteface to the database routines.
@@ -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 ff38bfab799a8739cd9f3e23a3216dc3591b817e..76824e1135be9ed22abb21c4629a77a4a7e2b9c2 100644 (file)
@@ -1,4 +1,4 @@
-/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/misc.c,v 1.26 2005/10/15 02:49:47 momjian Exp $ */
+/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/misc.c,v 1.26.2.1 2006/06/21 11:38:26 meskes Exp $ */
 
 #define POSTGRES_ECPG_INTERNAL
 #include "postgres_fe.h"
@@ -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)