diff options
author | Timo Sirainen <cras@irssi.org> | 2000-11-30 01:14:49 +0000 |
---|---|---|
committer | cras <cras@dbcabf3a-b0e7-0310-adc4-f8d773084564> | 2000-11-30 01:14:49 +0000 |
commit | cbf45ea6bfeb12c4b7f98c66c5ffcf204f81a8ce (patch) | |
tree | 33fc14f6939ea7c53aad911687bacba1854308a0 /src | |
parent | 1d48bc59ac140fae3a868d8470933feefa9d41bd (diff) | |
download | irssi-cbf45ea6bfeb12c4b7f98c66c5ffcf204f81a8ce.zip |
stristr() and stristr_full() didn't work correctly with empty needle
argument.
git-svn-id: http://svn.irssi.org/repos/irssi/trunk@898 dbcabf3a-b0e7-0310-adc4-f8d773084564
Diffstat (limited to 'src')
-rw-r--r-- | src/core/misc.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/core/misc.c b/src/core/misc.c index 9115f29a..37e6a001 100644 --- a/src/core/misc.c +++ b/src/core/misc.c @@ -307,8 +307,10 @@ char *stristr(const char *data, const char *key) keylen = strlen(key); datalen = strlen(data); - if (keylen > datalen || keylen == 0) + if (keylen > datalen) return NULL; + if (keylen == 0) + return (char *) data; max = data+datalen-keylen; pos = 0; @@ -339,8 +341,10 @@ char *stristr_full(const char *data, const char *key) keylen = strlen(key); datalen = strlen(data); - if (keylen > datalen || keylen == 0) + if (keylen > datalen) return NULL; + if (keylen == 0) + return (char *) data; max = data+datalen-keylen; start = data; pos = 0; |