diff options
author | Darren Salt <linux@youmustbejoking.demon.co.uk> | 2008-01-09 22:19:42 +0000 |
---|---|---|
committer | Darren Salt <linux@youmustbejoking.demon.co.uk> | 2008-01-09 22:19:42 +0000 |
commit | 2a9d1fe9f99cc2329a762f6e30a8ee0dc8e84014 (patch) | |
tree | e6de82180542abdc733fb874a5257c38c5fea8a5 /lib | |
parent | c749ef5ef58af5f1a1856c802b0726bf6912601a (diff) | |
download | xine-lib-2a9d1fe9f99cc2329a762f6e30a8ee0dc8e84014.tar.gz xine-lib-2a9d1fe9f99cc2329a762f6e30a8ee0dc8e84014.tar.bz2 |
Fix a read-past-end bug in xine-lib's internal strtok_r replacement.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/strtok_r.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/lib/strtok_r.c b/lib/strtok_r.c index cead029a2..8a5284a42 100644 --- a/lib/strtok_r.c +++ b/lib/strtok_r.c @@ -19,7 +19,7 @@ char *xine_private_strtok_r(char *s, const char *delim, char **ptrptr) { else s = *ptrptr; /* end of searching */ - if (!s || s == '\0') return NULL; + if (!s || !*s) return NULL; /* cut the initial garbage */ cutlen = strspn(s, delim); @@ -32,12 +32,12 @@ char *xine_private_strtok_r(char *s, const char *delim, char **ptrptr) { } next = s + toklen; + /* prepare next call */ + *ptrptr = *next ? next + 1 : NULL; + /* cut current token */ *next = '\0'; - /* prepare next call */ - *ptrptr = next + 1; - /* return the token */ return s; } |