]> git.ipfire.org Git - thirdparty/grub.git/commit
gnulib/regexec: Fix resource leak
authorAlec Brown <alec.r.brown@oracle.com>
Tue, 10 Jun 2025 15:19:45 +0000 (15:19 +0000)
committerDaniel Kiper <daniel.kiper@oracle.com>
Tue, 17 Jun 2025 12:29:29 +0000 (14:29 +0200)
commitdb506b3b83640ab166a782e1ca47c47836afddcd
tree88cbc85d95fe5894ebf5c2a04f39dc11b9a6323e
parentbba7dd7363402157034e9c94ee3d9ea82e37861d
gnulib/regexec: Fix resource leak

In the function merge_state_with_log(), memory is allocated for the variable
next_nodes when creating a union of the variables table_nodes and log_nodes.
However, if next_state->entrance_nodes is NULL, then table_nodes becomes NULL
and we still allocate memory to copy the content of log_nodes. This can cause
a resource leak since we only free the memory for next_nodes if table_nodes
isn't NULL. To prevent this, we need to check that next_state->entrance_nodes
isn't NULL before allocating memory for the union.

This issue has been fixed in the latest version of gnulib and I've backported
this change to maintain consistency.

This issue was found by a Coverity scan of GRUB2 under the CID 473887.

Fixes: CID 473887
Signed-off-by: Alec Brown <alec.r.brown@oracle.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
bootstrap.conf
conf/Makefile.extra-dist
grub-core/lib/gnulib-patches/fix-regexec-resource-leak.patch [new file with mode: 0644]