Skip to content

Commit

Permalink
Fix NULL in strdup
Browse files Browse the repository at this point in the history
  • Loading branch information
Caerbannog committed Jan 18, 2015
1 parent 23ddfa4 commit 09fdd8e
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion httpclient.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,14 @@ typedef struct {

static char * esp_strdup(const char * str)
{
if (str == NULL) {
return NULL;
}
char * new_str = (char *)os_malloc(os_strlen(str) + 1); // 1 for null character
if (new_str == NULL)
if (new_str == NULL) {
os_printf("esp_strdup: malloc error");
return NULL;
}
os_strcpy(new_str, str);
return new_str;
}
Expand Down

0 comments on commit 09fdd8e

Please sign in to comment.