Skip to content

Commit

Permalink
ut: fix *_strdup() functions
Browse files Browse the repository at this point in the history
  • Loading branch information
razvancrainea committed Dec 7, 2017
1 parent ec04149 commit 595c915
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions ut.h
Expand Up @@ -639,11 +639,12 @@ static inline char *shm_strdup(const char *str)
if (!str)
return NULL;

len = strlen(str) + 1;
rval = shm_malloc(len);
len = strlen(str);
rval = shm_malloc(len + 1);
if (!rval)
return NULL;
memcpy(rval, str, len);
rval[len] = '\0';
return rval;
}

Expand Down Expand Up @@ -691,11 +692,12 @@ static inline char *pkg_strdup(const char *str)
if (!str)
return NULL;

len = strlen(str) + 1;
rval = pkg_malloc(len);
len = strlen(str);
rval = pkg_malloc(len + 1);
if (!rval)
return NULL;
memcpy(rval, str, len);
rval[len] = '\0';
return rval;
}

Expand Down

0 comments on commit 595c915

Please sign in to comment.