makefs: Plug a memory leak

nvlist_find_string() would return a copy of the found value, but callers
assumed they would have to make their own copy.  It's simpler to change
nvlist_find_string() than it is to change callers, so do that.

Reported by:	Coverity
This commit is contained in:
Mark Johnston 2022-10-04 12:46:39 -04:00
parent 47218e711e
commit d7eec79b70

View File

@ -75,10 +75,8 @@ nvlist_find_string(nvlist_t *nvl, const char *key, char **retp)
int error, len;
error = nvlist_find(nvl, key, DATA_TYPE_STRING, NULL, &str, &len);
if (error == 0) {
*retp = ecalloc(1, len + 1);
memcpy(*retp, str, len);
}
if (error == 0)
*retp = str;
return (error);
}