summaryrefslogtreecommitdiffstats
path: root/kjs
diff options
context:
space:
mode:
authorSlávek Banko <slavek.banko@axis.cz>2024-09-08 12:20:25 +0200
committerSlávek Banko <slavek.banko@axis.cz>2024-09-08 12:38:41 +0200
commit269661fa811c8efbbf014bf2ce039eeb1313af47 (patch)
tree20437203339243d22dae357c4133490ef060d8d6 /kjs
parente034c819b9f578c5b4b468626846a22e84d55a8f (diff)
downloadtdelibs-269661fa811c8efbbf014bf2ce039eeb1313af47.tar.gz
tdelibs-269661fa811c8efbbf014bf2ce039eeb1313af47.zip
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 3150a4542f81f0f953e68170bda462b0a501ff29)
Diffstat (limited to 'kjs')
-rw-r--r--kjs/regexp.cpp1
1 files changed, 1 insertions, 0 deletions
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;
}