[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: string-desc: Fix undefined behaviour
From: |
Bruno Haible |
Subject: |
Re: string-desc: Fix undefined behaviour |
Date: |
Tue, 10 Sep 2024 05:00:47 +0200 |
Jeffrey Walton wrote:
> > if (needle._nbytes == 0)
> > return 0;
> > + if (haystack._nbytes == 0)
> > + return -1;
> > void *found =
> > memmem (haystack._data, haystack._nbytes, needle._data,
> > needle._nbytes);
> > if (found != NULL)
>
> Clang is complaining haystack._data is NULL, not needle._nbytes is 0.
The set of inputs with haystack._data == NULL is a subset of
the set of inputs with haystack._nbytes == 0.
Bruno