Merge pull request #13637 from yyuanam/fix_vtysh_core

lib: fix vtysh core when handling questionmark
This commit is contained in:
Donatas Abraitis 2023-06-01 22:30:50 +03:00 committed by GitHub
commit 89eaf9b7a0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -735,9 +735,13 @@ char *cmd_variable_comp2str(vector comps, unsigned short cols)
char *item = vector_slot(comps, j);
itemlen = strlen(item);
if (cs + itemlen + AUTOCOMP_INDENT + 3 >= bsz)
buf = XREALLOC(MTYPE_TMP, buf, (bsz *= 2));
size_t next_sz = cs + itemlen + AUTOCOMP_INDENT + 3;
if (next_sz > bsz) {
/* Make sure the buf size is large enough */
bsz = next_sz;
buf = XREALLOC(MTYPE_TMP, buf, bsz);
}
if (lc + itemlen + 1 >= cols) {
cs += snprintf(&buf[cs], bsz - cs, "\n%*s",
AUTOCOMP_INDENT, "");