From ff8f2710f6eab21888223fac3a8d8a8d4549d201 Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Fri, 29 Jun 2018 19:11:02 +0200 Subject: Check return value of pcre2_maketables() --- ext/pcre/php_pcre.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'ext/pcre/php_pcre.c') diff --git a/ext/pcre/php_pcre.c b/ext/pcre/php_pcre.c index e46c83accc..c365c9f475 100644 --- a/ext/pcre/php_pcre.c +++ b/ext/pcre/php_pcre.c @@ -720,6 +720,13 @@ PHPAPI pcre_cache_entry* pcre_get_compiled_regex_cache(zend_string *regex) tables = (uint8_t *)zend_hash_find_ptr(&char_tables, BG(locale_string)); if (!tables) { tables = pcre2_maketables(gctx); + if (UNEXPECTED(!tables)) { + php_error_docref(NULL,E_WARNING, "Failed to generate locale character tables"); + pcre_handle_exec_error(PCRE2_ERROR_NOMEMORY); + zend_string_release_ex(key, 0); + efree(pattern); + return NULL; + } zend_hash_add_ptr(&char_tables, BG(locale_string), (void *)tables); } pcre2_set_character_tables(cctx, tables); -- cgit v1.2.1