lbutils/file ffree_and_set_null: err if null

free can take a null, that's fine, but my pointer
to the pointer being freed should not be null. that
is a bug.

Signed-off-by: Leah Rowe <leah@libreboot.org>
This commit is contained in:
Leah Rowe
2026-03-28 07:47:31 +00:00
parent 63984a4a6a
commit 03dd3c2894
+5 -1
View File
@@ -578,7 +578,11 @@ try_err(int loop_err, int errval)
void
free_and_set_null(char **buf)
{
if (buf == NULL || *buf == NULL)
if (buf == NULL)
err_exit(EFAULT,
"null ptr (to ptr for freeing) in free_and_set_null");
if (*buf == NULL)
return;
free(*buf);