Skip to content

Commit edcf087

Browse files
committed
Avoid potentially-uninitialized warnings in readline
1 parent e5edbd0 commit edcf087

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

ext/readline/readline_cli.c

+4-5
Original file line numberDiff line numberDiff line change
@@ -521,13 +521,12 @@ static char *cli_completion_generator(const char *text, int index) /* {{{ */
521521
retval = cli_completion_generator_ini(text, textlen, &cli_completion_state);
522522
} else {
523523
char *lc_text, *class_name_end;
524-
size_t class_name_len;
525-
zend_string *class_name;
524+
zend_string *class_name = NULL;
526525
zend_class_entry *ce = NULL;
527526

528527
class_name_end = strstr(text, "::");
529528
if (class_name_end) {
530-
class_name_len = class_name_end - text;
529+
size_t class_name_len = class_name_end - text;
531530
class_name = zend_string_alloc(class_name_len, 0);
532531
zend_str_tolower_copy(ZSTR_VAL(class_name), text, class_name_len);
533532
if ((ce = zend_lookup_class(class_name)) == NULL) {
@@ -561,11 +560,11 @@ static char *cli_completion_generator(const char *text, int index) /* {{{ */
561560
break;
562561
}
563562
efree(lc_text);
564-
if (class_name_end) {
563+
if (class_name) {
565564
zend_string_release_ex(class_name, 0);
566565
}
567566
if (ce && retval) {
568-
size_t len = class_name_len + 2 + strlen(retval) + 1;
567+
size_t len = ZSTR_LEN(ce->name) + 2 + strlen(retval) + 1;
569568
char *tmp = malloc(len);
570569

571570
snprintf(tmp, len, "%s::%s", ZSTR_VAL(ce->name), retval);

0 commit comments

Comments
 (0)