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>
pull/301/head
Slávek Banko 3 months ago
parent 8166c26c7a
commit 3150a4542f
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