[PATCH] mdev: add NULL-checks in clean_up_cur_rule()
Kang-Che Sung
explorer09 at gmail.com
Mon Aug 19 19:49:11 UTC 2024
Maks Mishin <maks.mishinfz at gmail.com> 於 2024年8月19日 星期一寫道:
> The function clean_up_cur_rule() calls in the loop, which can lead to
> double-free of pointers `G.cur_rule.envvar` and `G.cur_rule.ren_mov`.
> Added NULL checks and NULL assignment after free for correct checks.
>
> - free(G.cur_rule.envvar);
> - free(G.cur_rule.ren_mov);
> + if (G.cur_rule.envvar != NULL) {
> + free(G.cur_rule.envvar);
> + G.cur_rule.envvar = NULL;
> + }
> + if (G.cur_rule.ren_mov != NULL) {
> + free(G.cur_rule.ren_mov);
> + G.cur_rule.ren_mov = NULL;
> + }
> +
libc free() function should do no-op if the argument is NULL. Thus the
check for NULL conditionals may be removed.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.busybox.net/pipermail/busybox/attachments/20240820/4ea0d24c/attachment.html>
More information about the busybox
mailing list