[Top][All Lists]

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

Re: vasnprintf.c: "out_of_memory", -Wanalyzer-free-of-non-heap, -Wanalyz

From: Paul Eggert
Subject: Re: vasnprintf.c: "out_of_memory", -Wanalyzer-free-of-non-heap, -Wanalyzer-malloc-leak
Date: Sat, 30 Apr 2022 19:47:30 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.8.1

On 4/30/22 17:24, Bruno Haible wrote:
These dependencies save an 'errno = ENOMEM;' assignment in one or
two places, but can cause integration problems; I am especially
thinking at the use in GNU libintl and libasprintf.

Ah, I didn't know about the integration problems. I was worried about the case where malloc fails with some errno value other than ENOMEM and that errno value should be reflected to the user; but that's less important than getting integration right. (malloc can fail with EAGAIN on GNU/Linux and I assume other errno values are also possible.)

It would be worth to eliminate the false positive reports by GCC.

Yes, though the weird thing is I'm also using GCC 11.3.1 and am not getting the false positives.

We could
   assume (result==resultbuf)
for one part.

I am surprised GCC doesn't deduce that itself; it's part of that same weird thing.

If this happens only with unusual configuration settings I expect we don't need to worry about it. It's just a warning....

buf_malloced is NULL 99% of the time; here I prefer the code
that saves a function call.

Good point; hadn't noticed that. I suppose this can also help make branch prediction more accurate.

reply via email to

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