bug-gnulib
[Top][All Lists]
Advanced

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

Re: Fix memleak in getdelim.m4


From: Bruno Haible
Subject: Re: Fix memleak in getdelim.m4
Date: Thu, 21 May 2020 21:38:55 +0200
User-agent: KMail/5.1.3 (Linux/4.4.0-177-generic; KDE/5.18.0; x86_64; ; )

Paul Eggert wrote:
> > -      if (memmem (haystack, 3, NULL, 0) != haystack)
> > +      if (memmem (haystack, 3, (const char *) 1, 0) != haystack)
> 
> This has undefined behavior in general, no?

No. memmem is not supposed to access more than NEEDLELEN bytes at NEEDLE.

> How about using '""' instead of '(const char *) 1'?

That would defeat the purpose of the test, which is to test for the glibc 2.0
bug [1].

Bruno

[1] http://man7.org/linux/man-pages/man3/memmem.3.html




reply via email to

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