kjs - pcre: Fix crash if regexp is invalid.

If the regular expression is invalid and pcre2_compile ends with error,
match_data will remain uninitialized, which in turn leads to crash on
pcre2_match_data_free in RegExp destructor.

Signed-off-by: Slávek Banko <slavek.banko@axis.cz>
(cherry picked from commit 3150a4542f)
pull/312/head
Slávek Banko 3 months ago
parent e034c819b9
commit 269661fa81
No known key found for this signature in database
GPG Key ID: 608F5293A04BE668

@ -149,6 +149,7 @@ RegExp::RegExp(const UString &p, int f)
pcre2_get_error_message(errorCode, errorMsg, sizeof(errorMsg)); pcre2_get_error_message(errorCode, errorMsg, sizeof(errorMsg));
fprintf(stderr, "KJS: pcre_compile() failed with '%s'\n", errorMsg); fprintf(stderr, "KJS: pcre_compile() failed with '%s'\n", errorMsg);
#endif #endif
match_data = nullptr;
valid = false; valid = false;
return; return;
} }

Loading…
Cancel
Save