Null check before dereference

Fix Coverity error CID 56880

Signed-off-by: Gregor Jasny <gjasny@googlemail.com>
This commit is contained in:
Gregor Jasny 2014-09-28 22:19:23 +02:00 committed by David Drysdale
parent 880ec44da9
commit 13dc4800b2
1 changed files with 3 additions and 0 deletions

View File

@ -158,6 +158,9 @@ int ares_set_servers_csv(ares_channel channel,
return ARES_SUCCESS; /* blank all servers */
csv = malloc(i + 2);
if (!csv)
return ARES_ENOMEM;
strcpy(csv, _csv);
if (csv[i-1] != ',') { /* make parsing easier by ensuring ending ',' */
csv[i] = ',';