[File] [PATCH] regex handling in file_regfree

Christos Zoulas christos at zoulas.com
Sat May 16 11:22:12 EDT 2026


No, just too busy :-(
Took care of it!

Thanks,

christos

> On May 14, 2026, at 3:01 PM, Steve Grubb <sgrubb at redhat.com> wrote:
> 
> 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
> 
> 
> 
> 
> -- 
> File mailing list
> File at astron.com
> https://mailman.astron.com/mailman/listinfo/file

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 235 bytes
Desc: Message signed with OpenPGP
URL: <http://mailman.astron.com/pipermail/file/attachments/20260516/92f2d4dc/attachment.asc>


More information about the File mailing list