bug-bash
[Top][All Lists]
Advanced

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

Re: Some compile-time warnings


From: Chet Ramey
Subject: Re: Some compile-time warnings
Date: Tue, 30 Sep 2025 07:18:05 -0400
User-agent: Mozilla Thunderbird

On 9/29/25 5:15 PM, Collin Funk wrote:
Chet Ramey <chet.ramey@case.edu> writes:

On 9/29/25 1:00 AM, Martin D Kealey wrote:

The malloc size warning is concerning, as the excessive “size” is
(uint64_t)(-1).

It seems theoretical, since the line in question is

temp = pointer ? realloc (pointer, bytes) : malloc (bytes);

and `bytes' is a size_t, which matches realloc's and malloc's prototypes.

You can probably just add a check add something like:

     if (bytes < PTRDIFF_MAX)
       {
          errno = ENOMEM;
          return NULL;
       }

to silence it (although I haven't tested it).

I hate adding code just to silence spurious warnings.

--
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    chet@case.edu    http://tiswww.cwru.edu/~chet/

Attachment: OpenPGP_signature.asc
Description: OpenPGP digital signature


reply via email to

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