Skip to content

Commit

Permalink
Fix issue sibaz#4 - match array not initialized
Browse files Browse the repository at this point in the history
Done like in function php_pcre_match_impl() of PCRE module.
  • Loading branch information
Eik Rentzow committed Feb 28, 2023
1 parent 9d83d26 commit cc2e72e
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions expect.c
Original file line number Diff line number Diff line change
Expand Up @@ -452,11 +452,15 @@ PHP_FUNCTION(expect_expectl)
if (z_match && exp_match && exp_match_len > 0) {
char *tmp = (char *)emalloc (sizeof(char) * (exp_match_len + 1));
strlcpy (tmp, exp_match, exp_match_len + 1);
zval_dtor (z_match);
array_init(z_match);
#if PHP_MAJOR_VERSION >= 7
z_match = zend_try_array_init(z_match);
if (!z_match) {
return;
}
add_index_string(z_match, 0, tmp);
#else
zval_dtor (z_match);
array_init(z_match);
add_index_string(z_match, 0, tmp, 1);
#endif
/* Get case that was matched */
Expand Down

0 comments on commit cc2e72e

Please sign in to comment.