diff options
author | Alvaro Herrera <alvherre@alvh.no-ip.org> | 2013-07-23 17:23:28 -0400 |
---|---|---|
committer | Alvaro Herrera <alvherre@alvh.no-ip.org> | 2013-07-23 17:35:22 -0400 |
commit | bb686c9a865dc15a704e6a96367b3d7bfe79df6f (patch) | |
tree | 1e33367d45ce57139e41b9ede95974f50a1aab4f | |
parent | a7cd853b75d01666135ca87353cee83b99d06b9b (diff) | |
download | postgresql-bb686c9a865dc15a704e6a96367b3d7bfe79df6f.tar.gz postgresql-bb686c9a865dc15a704e6a96367b3d7bfe79df6f.zip |
Check for NULL result from strdup
Per Coverity Scan
-rw-r--r-- | src/interfaces/libpq/fe-secure.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/interfaces/libpq/fe-secure.c b/src/interfaces/libpq/fe-secure.c index 174cf426f06..a6a09cd1ab2 100644 --- a/src/interfaces/libpq/fe-secure.c +++ b/src/interfaces/libpq/fe-secure.c @@ -1131,7 +1131,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 */ |