@@ -831,6 +831,7 @@ PHPAPI pcre_cache_entry* pcre_get_compiled_regex_cache_ex(zend_string *regex, bo
831831 if (key != regex ) {
832832 zend_string_release_ex (key , 0 );
833833 }
834+ pcre2_code_free (new_entry .re );
834835 php_error_docref (NULL , E_WARNING , "Internal pcre2_pattern_info() error %d" , rc );
835836 pcre_handle_exec_error (PCRE2_ERROR_INTERNAL );
836837 return NULL ;
@@ -841,6 +842,7 @@ PHPAPI pcre_cache_entry* pcre_get_compiled_regex_cache_ex(zend_string *regex, bo
841842 if (key != regex ) {
842843 zend_string_release_ex (key , 0 );
843844 }
845+ pcre2_code_free (new_entry .re );
844846 php_error_docref (NULL , E_WARNING , "Internal pcre_pattern_info() error %d" , rc );
845847 pcre_handle_exec_error (PCRE2_ERROR_INTERNAL );
846848 return NULL ;
@@ -1286,7 +1288,18 @@ PHPAPI void php_pcre_match_impl(pcre_cache_entry *pce, zend_string *subject_str,
12861288 if (subpats != NULL ) {
12871289 /* Try to get the list of substrings and display a warning if failed. */
12881290 if (UNEXPECTED (offsets [1 ] < offsets [0 ])) {
1289- if (match_sets ) efree (match_sets );
1291+ if (match_sets ) {
1292+ for (i = 0 ; i < num_subpats ; i ++ ) {
1293+ zend_array_destroy (match_sets [i ]);
1294+ }
1295+ efree (match_sets );
1296+ }
1297+ if (marks ) {
1298+ zend_array_destroy (marks );
1299+ }
1300+ if (match_data != mdata ) {
1301+ pcre2_match_data_free (match_data );
1302+ }
12901303 php_error_docref (NULL , E_WARNING , "Get subpatterns list failed" );
12911304 RETURN_FALSE ;
12921305 }
0 commit comments