libsemanage: never call memcpy with a NULL value
clang's static analyzer reports "Argument with 'nonnull' attribute passed null" in append_str(), because argument t may be NULL but is used in a call to memcpy(). Make append_str() do nothing when called with t=NULL. Signed-off-by: Nicolas Iooss <nicolas.iooss@m4x.org>
This commit is contained in:
parent
ddaf0afec7
commit
4176a29235
|
@ -1194,8 +1194,14 @@ static char *append(char *s, char c)
|
|||
static char *append_str(char *s, const char *t)
|
||||
{
|
||||
size_t s_len = (s == NULL ? 0 : strlen(s));
|
||||
size_t t_len = (t == NULL ? 0 : strlen(t));
|
||||
char *new_s = realloc(s, s_len + t_len + 1);
|
||||
size_t t_len;
|
||||
char *new_s;
|
||||
|
||||
if (t == NULL) {
|
||||
return s;
|
||||
}
|
||||
t_len = strlen(t);
|
||||
new_s = realloc(s, s_len + t_len + 1);
|
||||
if (new_s == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue