summaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
authorLeah Rowe <leah@libreboot.org>2026-03-28 07:47:31 +0000
committerLeah Rowe <leah@libreboot.org>2026-03-28 07:47:31 +0000
commit03dd3c289439e46ba0c5840cc7ab73b3c3fa60a3 (patch)
tree0c8d048d0714b57e441c816b495e10911a09b31a /util
parent63984a4a6abb7a65098f27196fcb6395fc0ada22 (diff)
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>
Diffstat (limited to 'util')
-rw-r--r--util/libreboot-utils/lib/file.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/util/libreboot-utils/lib/file.c b/util/libreboot-utils/lib/file.c
index 2b1adca8..3c7a3ba2 100644
--- a/util/libreboot-utils/lib/file.c
+++ b/util/libreboot-utils/lib/file.c
@@ -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);