]> granicus.if.org Git - postgresql/commitdiff
Check for NULL result from strdup
authorAlvaro Herrera <alvherre@alvh.no-ip.org>
Tue, 23 Jul 2013 21:38:31 +0000 (17:38 -0400)
committerAlvaro Herrera <alvherre@alvh.no-ip.org>
Tue, 23 Jul 2013 21:38:31 +0000 (17:38 -0400)
Per Coverity Scan

src/interfaces/libpq/fe-secure.c

index 29936deb9d1a7a2bd04457a03a73042690ec6b03..a3edbe63d745ea85e2770082a2597588ee5f09cf 100644 (file)
@@ -1130,7 +1130,17 @@ initialize_SSL(PGconn *conn)
                {
                        /* Colon, but not in second character, treat as engine:key */
                        char       *engine_str = strdup(conn->sslkey);
-                       char       *engine_colon = strchr(engine_str, ':');
+                       char       *engine_colon;
+
+                       if (engine_str == NULL)
+                       {
+                               printfPQExpBuffer(&conn->errorMessage,
+                                                                 libpq_gettext("out of memory\n"));
+                               return -1;
+                       }
+
+                       /* cannot return NULL because we already checked before strdup */
+                       engine_colon = strchr(engine_str, ':');
 
                        *engine_colon = '\0';           /* engine_str now has engine name */
                        engine_colon++;         /* engine_colon now has key name */