Skip to content

Commit e12c069

Browse files
committed
Add fallbacks for older oniguruma versions
1 parent bc4cb27 commit e12c069

File tree

2 files changed

+25
-2
lines changed

2 files changed

+25
-2
lines changed

ext/mbstring/mbstring.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,17 @@
6565
#include "php_onig_compat.h"
6666
#include <oniguruma.h>
6767
#undef UChar
68+
#if ONIGURUMA_VERSION_INT < 60800
69+
typedef void OnigMatchParam;
70+
#define onig_new_match_param() (NULL)
71+
#define onig_initialize_match_param(x)
72+
#define onig_set_match_stack_limit_size_of_match_param(x, y)
73+
#define onig_free_match_param(x)
74+
#define onig_search_with_param(reg, str, end, start, range, region, option, mp) \
75+
onig_search(reg, str, end, start, range, region, option)
76+
#define onig_match_with_param(re, str, end, at, region, option, mp) \
77+
onig_match(re, str, end, at, region, option)
78+
#endif
6879
#elif HAVE_PCRE || HAVE_BUNDLED_PCRE
6980
#include "ext/pcre/php_pcre.h"
7081
#endif
@@ -1030,7 +1041,7 @@ static int _php_mb_match_regex(void *opaque, const char *str, size_t str_len)
10301041
OnigMatchParam *mp = onig_new_match_param();
10311042
int err;
10321043
onig_initialize_match_param(mp);
1033-
if(MBSTRG(regex_stack_limit) > 0 && MBSTRG(regex_stack_limit) < UINT_MAX) {
1044+
if (!ZEND_LONG_UINT_OVFL(MBSTRG(regex_stack_limit))) {
10341045
onig_set_match_stack_limit_size_of_match_param(mp, (unsigned int)MBSTRG(regex_stack_limit));
10351046
}
10361047
/* search */

ext/mbstring/php_mbregex.c

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,18 @@
3434
#include <oniguruma.h>
3535
#undef UChar
3636

37+
#if ONIGURUMA_VERSION_INT < 60800
38+
typedef void OnigMatchParam;
39+
#define onig_new_match_param() (NULL)
40+
#define onig_initialize_match_param(x)
41+
#define onig_set_match_stack_limit_size_of_match_param(x, y)
42+
#define onig_free_match_param(x)
43+
#define onig_search_with_param(reg, str, end, start, range, region, option, mp) \
44+
onig_search(reg, str, end, start, range, region, option)
45+
#define onig_match_with_param(re, str, end, at, region, option, mp) \
46+
onig_match(re, str, end, at, region, option)
47+
#endif
48+
3749
ZEND_EXTERN_MODULE_GLOBALS(mbstring)
3850

3951
struct _zend_mb_regex_globals {
@@ -856,7 +868,7 @@ static int _php_mb_onig_search(regex_t* reg, const OnigUChar* str, const OnigUCh
856868
OnigMatchParam *mp = onig_new_match_param();
857869
int err;
858870
onig_initialize_match_param(mp);
859-
if(MBSTRG(regex_stack_limit) > 0 && MBSTRG(regex_stack_limit) < UINT_MAX) {
871+
if (!ZEND_LONG_UINT_OVFL(MBSTRG(regex_stack_limit))) {
860872
onig_set_match_stack_limit_size_of_match_param(mp, (unsigned int)MBSTRG(regex_stack_limit));
861873
}
862874
/* search */

0 commit comments

Comments
 (0)