fix(find.c): Ensure 'pattlen' is non-zero
This commit is contained in:
@ -694,9 +694,13 @@ int findinit(const char *pattern_) {
|
|||||||
/* Pattern length */
|
/* Pattern length */
|
||||||
size_t pattlen = strlen(pattern);
|
size_t pattlen = strlen(pattern);
|
||||||
|
|
||||||
/* remove trailing white space */
|
/* 04-12-2024 23:27 yama
|
||||||
for(s = pattern + (pattlen - 1); isspace((unsigned char)*s); --s) {
|
* NOTE: It is necessary to check the length because 'pattern' && 'pattern_'
|
||||||
*s = '\0';
|
could be non-null while still being 0 length.
|
||||||
|
*/
|
||||||
|
if (pattlen == 0) {
|
||||||
|
free(pattern);
|
||||||
|
return NOTSYMBOL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Make sure pattern is lowercased. Curses
|
/* Make sure pattern is lowercased. Curses
|
||||||
|
Reference in New Issue
Block a user