summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTimo Sirainen <cras@irssi.org>2000-11-30 01:14:49 +0000
committercras <cras@dbcabf3a-b0e7-0310-adc4-f8d773084564>2000-11-30 01:14:49 +0000
commitcbf45ea6bfeb12c4b7f98c66c5ffcf204f81a8ce (patch)
tree33fc14f6939ea7c53aad911687bacba1854308a0 /src
parent1d48bc59ac140fae3a868d8470933feefa9d41bd (diff)
downloadirssi-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.c8
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;