Skip to content

Commit ff8f271

Browse files
committed
Check return value of pcre2_maketables()
1 parent 4ff6c0c commit ff8f271

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

ext/pcre/php_pcre.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -720,6 +720,13 @@ PHPAPI pcre_cache_entry* pcre_get_compiled_regex_cache(zend_string *regex)
720720
tables = (uint8_t *)zend_hash_find_ptr(&char_tables, BG(locale_string));
721721
if (!tables) {
722722
tables = pcre2_maketables(gctx);
723+
if (UNEXPECTED(!tables)) {
724+
php_error_docref(NULL,E_WARNING, "Failed to generate locale character tables");
725+
pcre_handle_exec_error(PCRE2_ERROR_NOMEMORY);
726+
zend_string_release_ex(key, 0);
727+
efree(pattern);
728+
return NULL;
729+
}
723730
zend_hash_add_ptr(&char_tables, BG(locale_string), (void *)tables);
724731
}
725732
pcre2_set_character_tables(cctx, tables);

0 commit comments

Comments
 (0)