[PATCH] avoid -Wuse-after-free [BZ #26779]
Martin Sebor
msebor@gmail.com
Thu Jan 20 21:50:15 GMT 2022
On 1/18/22 02:48, Florian Weimer wrote:
> * Martin Sebor via Libc-alpha:
>
>> GCC 12 features a couple of new warnings designed to detect uses
>> of pointers made invalid by the pointees lifetimes having ended.
>> Building Glibc with the enhanced GCC exposes a few such uses,
>> mostly after successful calls to realloc. The attached patch
>> avoids the new warnings by converting the pointers to uintptr_t
>> first and using the converted integers instead.
>>
>> The patch suppresses all instances of the warning at the strictest
>> setting (-Wuse-after-free=3), which includes even uses in equality
>> expressions. The default setting approved for GCC 12 is
>> -Wuse-after-free=2, which doesn't warn on such uses to accommodate
>> the pointer-adjustment-after-realloc idiom. At the default setting,
>> the changes to ldconfig.c and setenv are not necessary.
>
> Would you be able to split up this patch further? It will help with
> eventually backporting parts of it.
Sure. Let me fix the issues Paul pointed out and post a diff for
each file separately.
Martin
>
> Thanks,
> Florian
>
More information about the Libc-alpha
mailing list