Handle empty regular expression in substitution, found by ossfuzz.

This commit is contained in:
nicm
2026-04-02 08:45:35 +00:00
parent 8b51abef08
commit 1a51193899

View File

@@ -68,6 +68,8 @@ regsub(const char *pattern, const char *with, const char *text, int flags)
if (*text == '\0') if (*text == '\0')
return (xstrdup("")); return (xstrdup(""));
if (*pattern == '\0')
return (xstrdup(text));
if (regcomp(&r, pattern, flags) != 0) if (regcomp(&r, pattern, flags) != 0)
return (NULL); return (NULL);