Avoid an endless loop: Safeguard function

search_plain_identifier(char *str, const char *identifier)
against identifiers being an empty string.
This commit is contained in:
Holger Vogt 2022-08-01 18:30:50 +02:00
parent 227bb9c419
commit 874aca4a86
1 changed files with 3 additions and 2 deletions

View File

@ -5168,10 +5168,11 @@ char *ya_search_identifier(char *str, const char *identifier, char *str_begin)
return str;
}
/* Check for 'identifier' being in string str, surrounded by chars
not being a member of alphanumeric or '_' characters. */
char *search_plain_identifier(char *str, const char *identifier)
{
if (str && identifier) {
if (str && identifier && *identifier != '\0') {
char *str_begin = str;
while ((str = strstr(str, identifier)) != NULL) {
char before;