[File] [PATCH] regex handling in file_regfree
Steve Grubb
sgrubb at redhat.com
Fri Apr 3 01:39:41 UTC 2026
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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: regex-free.patch
Type: text/x-patch
Size: 626 bytes
Desc: not available
URL: <https://mailman.astron.com/pipermail/file/attachments/20260402/63f4c32c/attachment.bin>
More information about the File
mailing list