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

Re: libc6 bug or stupid programmer



> The following segfaults under libc6, works fine under libc5:
> 
> main() {
> 	strtok("test","z");
> }
> 
> Is this a bug in strtok or is that really an invalid way to call strtok?

The call is invalid. strtok() modifies the string that is its first
argument (it puts '\0's into it to split it), but string constants are
in read-only memory. Use -fwriteable-strings (not very nice...), or:

main() {
    char *p = strup("test");
	strtok(p,"z");
}

Roman


--
TO UNSUBSCRIBE FROM THIS MAILING LIST: e-mail the word "unsubscribe" to
debian-devel-request@lists.debian.org . 
Trouble?  e-mail to templin@bucknell.edu .


Reply to: