Skip to content

Commit

Permalink
Null check before dereference
Browse files Browse the repository at this point in the history
Fix Coverity error CID 56880

Signed-off-by: Gregor Jasny <gjasny@googlemail.com>
  • Loading branch information
gjasny authored and daviddrysdale committed Sep 30, 2014
1 parent 880ec44 commit 13dc480
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions ares_options.c
Expand Up @@ -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] = ',';
Expand Down

0 comments on commit 13dc480

Please sign in to comment.