Skip to content

Commit

Permalink
Avoid modifying the return value of readline_completion_function()
Browse files Browse the repository at this point in the history
The internal function `_readline_command_generator()` modifies the
internal array pointer of `readline_completion_function()`'s return
value.  We therefore separate the array, what also avoids failing
assertions regarding the array refcount.

Closes GH-6582.
  • Loading branch information
cmb69 committed Jan 7, 2021
1 parent d1b1c04 commit 9450893
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions ext/readline/readline.c
Original file line number Diff line number Diff line change
Expand Up @@ -555,6 +555,7 @@ static char **_readline_completion_cb(const char *text, int start, int end)

if (call_user_function(NULL, NULL, &_readline_completion, &_readline_array, 3, params) == SUCCESS) {
if (Z_TYPE(_readline_array) == IS_ARRAY) {
SEPARATE_ARRAY(&_readline_array);
if (zend_hash_num_elements(Z_ARRVAL(_readline_array))) {
matches = rl_completion_matches(text,_readline_command_generator);
} else {
Expand Down

0 comments on commit 9450893

Please sign in to comment.