From 916a9d755a1660e086ef66d7113c2bcfc808a557 Mon Sep 17 00:00:00 2001 From: jvoisin Date: Sat, 8 May 2021 16:14:49 +0200 Subject: Handle a possible issue with regexp Gracefully handle the case where we can't get allocated memory when trying to match a regex. --- src/sp_pcre_compat.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/sp_pcre_compat.c b/src/sp_pcre_compat.c index 509a8ea..0d19769 100644 --- a/src/sp_pcre_compat.c +++ b/src/sp_pcre_compat.c @@ -34,6 +34,9 @@ bool ZEND_HOT sp_is_regexp_matching_len(const sp_pcre* regexp, const char* str, #ifdef SP_HAS_PCRE2 pcre2_match_data* match_data = pcre2_match_data_create_from_pattern(regexp, NULL); + if (NULL == match_data) { + sp_log_err("regexp", "Unable to get memory for a regxp."); + } ret = pcre2_match(regexp, (PCRE2_SPTR)str, len, 0, 0, match_data, NULL); #else int vec[30]; -- cgit v1.3