bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: gcc -fanalyze


From: Paul Eggert
Subject: Re: gcc -fanalyze
Date: Tue, 12 May 2020 09:32:46 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.7.0

On 5/11/20 2:11 PM, Bruno Haible wrote:

> xmalloc.c:113:10: warning: use of possibly-NULL '<unknown>' where non-null 
> expected [CWE-690] [-Wanalyzer-possible-null-argument]
> Since xmalloc (0) may be NULL, xmemdup may end up calling memcpy (NULL, p, 0).
> We know this is harmless, if no sanitizer is present at run time.
> But just to avoid triggering an undefined-behaviour sanitizer, we could treat 
> n == 0 specially.

To partially fix this I tuned xmalloc for when a GNU-compatible malloc is being
used by installing the attached patch. This is a micro-optimization for GNU
platforms (it omits a runtime test) and it pacifies GCC and/or other sanitizers
when a GNU-compatible malloc is being used. I hope that's good enough, since
people not using GNU-compatible malloc can either ignore the false alarm or add
the malloc-gnu module.

Attachment: 0001-xalloc-pacify-Wanalyzer-possible-null-argument.patch
Description: Text Data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]