[File] [PATCH] regex handling in file_regfree
Steve Grubb
sgrubb at redhat.com
Thu May 14 15:01:05 EDT 2026
Hello,
Just wondering if this fell off the radar?
Thanks,
-Steve
On Thursday, April 2, 2026 9:39:41 PM Eastern Daylight Time Steve Grubb
wrote:
> Hello,
>
> I noticed a small cleanup-safety issue around regex handling:
> file_regfree() always calls regfree().
>
> In two places, file_replace() and check_fmt(), cleanup was unconditional
> even when file_regcomp() returned non-zero.
>
> Since file_regcomp() can return an error, those paths can pass a regex
> object that was not successfully compiled into regfree(). Calling
> regfree() on a non-successfully-compiled regex is undefined behavior and
> can crash on some libc implementations.
>
> This patch just makes cleanup conditional on rc == 0 at those two call
> sites, with no API/structure changes.
>
> Behavior is otherwise unchanged.
> -Steve
More information about the File
mailing list