From 3150a4542f81f0f953e68170bda462b0a501ff29 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sl=C3=A1vek=20Banko?= Date: Sun, 8 Sep 2024 12:20:25 +0200 Subject: [PATCH] kjs - pcre: Fix crash if regexp is invalid. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- kjs/regexp.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/kjs/regexp.cpp b/kjs/regexp.cpp index a693fdc1a..c92a69d6a 100644 --- a/kjs/regexp.cpp +++ b/kjs/regexp.cpp @@ -149,6 +149,7 @@ RegExp::RegExp(const UString &p, int f) pcre2_get_error_message(errorCode, errorMsg, sizeof(errorMsg)); fprintf(stderr, "KJS: pcre_compile() failed with '%s'\n", errorMsg); #endif + match_data = nullptr; valid = false; return; }