This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Don't call strchr with the NULL character.


On Jul 11, 2013, at 12:15 PM, Andrew Burgess wrote:

> In the printf code we call strchr without guarding against the
> case where the second parameter is NULL.
> 
> My local manpage for strchr doesn't say what happens in this case,
> but this file:  src/libiberty/strchr.c
> suggests the results are undefined, and indeed, the answer I see is
> not NULL (which is what I might have hoped for).

The BSD manpage (for example on Mac OS) says:
     The strchr() function locates the first occurrence of c (converted to a
     char) in the string pointed to by s.  The terminating null character is
     considered to be part of the string; therefore if c is `\0', the func-
     tions locate the terminating `\0'.

It looks like libiberty/strchr.c does the same thing.  It doesn't look undefined at all. 

	paul


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]