This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: strtok behaviour when uninitialized
- From: Andreas Schwab <schwab at linux-m68k dot org>
- To: Salil Kapur <salilkapur93 at gmail dot com>
- Cc: libc-alpha at sourceware dot org
- Date: Sun, 11 Feb 2018 20:06:15 +0100
- Subject: Re: strtok behaviour when uninitialized
- Authentication-results: sourceware.org; auth=none
- References: <20180211181954.l5qkzway7zkd3345@salil> <878tbzwetl.fsf@linux-m68k.org> <20180211185345.jqcfijuchzkowkcx@salil>
On Feb 11 2018, Salil Kapur <salilkapur93@gmail.com> wrote:
> On Sun, Feb 11, 2018 at 07:39:50PM +0100, Andreas Schwab wrote:
>> On Feb 11 2018, Salil Kapur <salilkapur93@gmail.com> wrote:
>>
>> > Would it make sense to add a NULL check and not let strtok throw a
>> > segfault?
>>
>> No. This is undefined behaviour, and a crash is a valid and somewhat
>> appropriate reaction.
>
> I get that. Why keep it undefined?
Because it has no meaning.
Andreas.
--
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."