Skip to content

Commit 1143155

Browse files
committed
fix bug #72998
the function fn_complete in libedit null checks matches[2]
1 parent 29b083d commit 1143155

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ PHP NEWS
2828
- MySQLnd:
2929
. Fixed bug #80761 (PDO uses too much memory). (Nikita)
3030

31+
- readline:
32+
. Fixed bug #72998 (invalid read in readline completion). (krakjoe)
33+
3134
- Standard:
3235
. Fixed bug #81048 (phpinfo(INFO_VARIABLES) "Array to string conversion").
3336
(cmb)

ext/readline/readline.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -452,12 +452,12 @@ char **php_readline_completion_cb(const char *text, int start, int end)
452452
if (zend_hash_num_elements(Z_ARRVAL(_readline_array))) {
453453
matches = rl_completion_matches(text,_readline_command_generator);
454454
} else {
455-
matches = malloc(sizeof(char *) * 2);
455+
/* libedit will read matches[2] */
456+
matches = calloc(sizeof(char *), 3);
456457
if (!matches) {
457458
return NULL;
458459
}
459460
matches[0] = strdup("");
460-
matches[1] = NULL;
461461
}
462462
}
463463
}

0 commit comments

Comments
 (0)