util: strndup really stop and add null termination
Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
parent
c4d8cad1c5
commit
c8bd181b27
|
@ -215,7 +215,13 @@ static inline
|
|||
char * a_strndup(const char *s, ssize_t l)
|
||||
{
|
||||
ssize_t len = MIN(a_strlen(s), l);
|
||||
return len ? p_dup(s, len + 1) : NULL;
|
||||
if(len)
|
||||
{
|
||||
char *p = p_dup(s, len + 1);
|
||||
p[len] = '\0';
|
||||
return p;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/** \brief \c NULL resistant strcmp.
|
||||
|
|
Loading…
Reference in New Issue