Skip to content

Commit

Permalink
fix(dracut-install): release memory allocated for regular expressions
Browse files Browse the repository at this point in the history
Use `regfree` to free memory allocated by `regcomp`. Quoting [1]:

"If the preg argument to regexec() or regfree() is not a compiled regular
expression returned by regcomp(), the result is undefined."

Therefore, `regfree` must only be called if `regcomp` succeeded.

[1] https://pubs.opengroup.org/onlinepubs/9699919799/functions/regcomp.html
  • Loading branch information
aafeijoo-suse committed Nov 28, 2023
1 parent 4971f44 commit 26a93a9
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/install/dracut-install.c
Original file line number Diff line number Diff line change
Expand Up @@ -2275,6 +2275,17 @@ int main(int argc, char **argv)
hashmap_free(modules_suppliers);
hashmap_free(processed_suppliers);

if (arg_mod_filter_path)
regfree(&mod_filter_path);
if (arg_mod_filter_nopath)
regfree(&mod_filter_nopath);
if (arg_mod_filter_symbol)
regfree(&mod_filter_symbol);
if (arg_mod_filter_nosymbol)
regfree(&mod_filter_nosymbol);
if (arg_mod_filter_noname)
regfree(&mod_filter_noname);

strv_free(firmwaredirs);
strv_free(pathdirs);
return r;
Expand Down

0 comments on commit 26a93a9

Please sign in to comment.