Fix leak in libc NFSv4 flags parsing
Free memory allocated by strdup() in parse_flags_verbose(). Submitted by: Andrew Walker <walker.aj325_gmail.com> Reported by: valgrind Reviewed by: allanjude, freqlabs, rpokala MFC after: 3 days Sponsored by: iXsystems, Inc. Differential Revision: https://reviews.freebsd.org/D29871
This commit is contained in:
parent
b8be809495
commit
dd559118ab
@ -142,9 +142,10 @@ parse_flags_verbose(const char *strp, uint32_t *var,
|
||||
int *try_compact)
|
||||
{
|
||||
int i, found, ever_found = 0;
|
||||
char *str, *flag;
|
||||
char *str, *flag, *to_free;
|
||||
|
||||
str = strdup(strp);
|
||||
to_free = str;
|
||||
*try_compact = 0;
|
||||
*var = 0;
|
||||
|
||||
@ -166,12 +167,12 @@ parse_flags_verbose(const char *strp, uint32_t *var,
|
||||
"invalid flag \"%s\"", flags_name, flag);
|
||||
else
|
||||
*try_compact = 1;
|
||||
free(str);
|
||||
free(to_free);
|
||||
return (-1);
|
||||
}
|
||||
}
|
||||
|
||||
free(str);
|
||||
free(to_free);
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user