Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit bb686c9

Browse files
committed
Check for NULL result from strdup
Per Coverity Scan
1 parent a7cd853 commit bb686c9

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/interfaces/libpq/fe-secure.c

+11-1
Original file line numberDiff line numberDiff line change
@@ -1131,7 +1131,17 @@ initialize_SSL(PGconn *conn)
11311131
{
11321132
/* Colon, but not in second character, treat as engine:key */
11331133
char *engine_str = strdup(conn->sslkey);
1134-
char *engine_colon = strchr(engine_str, ':');
1134+
char *engine_colon;
1135+
1136+
if (engine_str == NULL)
1137+
{
1138+
printfPQExpBuffer(&conn->errorMessage,
1139+
libpq_gettext("out of memory\n"));
1140+
return -1;
1141+
}
1142+
1143+
/* cannot return NULL because we already checked before strdup */
1144+
engine_colon = strchr(engine_str, ':');
11351145

11361146
*engine_colon = '\0'; /* engine_str now has engine name */
11371147
engine_colon++; /* engine_colon now has key name */

0 commit comments

Comments
 (0)