diff options
| author | jvoisin | 2021-05-08 16:14:49 +0200 |
|---|---|---|
| committer | jvoisin | 2021-05-08 16:14:49 +0200 |
| commit | 916a9d755a1660e086ef66d7113c2bcfc808a557 (patch) | |
| tree | b1a81bdc920d33dafaa1414eb7820b554add7edb /src/sp_pcre_compat.c | |
| parent | 3babf77bb88c6dbd465e83b6da5946f273c890c1 (diff) | |
Handle a possible issue with regexp
Gracefully handle the case where we can't get
allocated memory when trying to match a regex.
Diffstat (limited to 'src/sp_pcre_compat.c')
| -rw-r--r-- | src/sp_pcre_compat.c | 3 |
1 files changed, 3 insertions, 0 deletions
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, | |||
| 34 | #ifdef SP_HAS_PCRE2 | 34 | #ifdef SP_HAS_PCRE2 |
| 35 | pcre2_match_data* match_data = | 35 | pcre2_match_data* match_data = |
| 36 | pcre2_match_data_create_from_pattern(regexp, NULL); | 36 | pcre2_match_data_create_from_pattern(regexp, NULL); |
| 37 | if (NULL == match_data) { | ||
| 38 | sp_log_err("regexp", "Unable to get memory for a regxp."); | ||
| 39 | } | ||
| 37 | ret = pcre2_match(regexp, (PCRE2_SPTR)str, len, 0, 0, match_data, NULL); | 40 | ret = pcre2_match(regexp, (PCRE2_SPTR)str, len, 0, 0, match_data, NULL); |
| 38 | #else | 41 | #else |
| 39 | int vec[30]; | 42 | int vec[30]; |
