diff options
| author | Donatas Abraitis <donatas@opensourcerouting.org> | 2023-06-01 22:30:50 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-06-01 22:30:50 +0300 |
| commit | 89eaf9b7a0feed634ef9f42ee6767418ee293b4b (patch) | |
| tree | 4a92d95e85a619652546b0683f91a563682b62eb /lib/command.c | |
| parent | 2cf6941f1dc5f45f45ff4268cef7ad784cff0e4e (diff) | |
| parent | f8aa257997a6a6f69ec5d5715ab04d7cbfae1d1c (diff) | |
Merge pull request #13637 from yyuanam/fix_vtysh_core
lib: fix vtysh core when handling questionmark
Diffstat (limited to 'lib/command.c')
| -rw-r--r-- | lib/command.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/command.c b/lib/command.c index e92251160f..0995637219 100644 --- a/lib/command.c +++ b/lib/command.c @@ -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, ""); |
