This is the mail archive of the
libc-alpha@sources.redhat.com
mailing list for the glibc project.
A patch for ./sysdeps/generic/strtok.c
- To: GNU C Library <libc-alpha at sourceware dot cygnus dot com>
- Subject: A patch for ./sysdeps/generic/strtok.c
- From: "H . J . Lu" <hjl at valinux dot com>
- Date: Thu, 22 Feb 2001 17:09:22 -0800
The new strtok testcase exposed a bug in sysdeps/generic/strtok.c. Here
is a patch. But it may not be the best one.
--
H.J. Lu (hjl@valinux.com)
--
2001-02-22 H.J. Lu <hjl@gnu.org>
* sysdeps/generic/strtok.c (strtok): Return NULL if `s' is
NULL.
Index: sysdeps/generic/strtok.c
===================================================================
RCS file: /work/cvs/gnu/glibc/sysdeps/generic/strtok.c,v
retrieving revision 1.1.1.2
diff -u -p -r1.1.1.2 strtok.c
--- sysdeps/generic/strtok.c 2000/08/16 00:57:41 1.1.1.2
+++ sysdeps/generic/strtok.c 2001/02/23 01:03:03
@@ -42,6 +42,9 @@ strtok (s, delim)
if (s == NULL)
s = olds;
+ if (s == NULL)
+ return NULL;
+
/* Scan leading delimiters. */
s += strspn (s, delim);
if (*s == '\0')