commit - 3dd0b26000acfddf863190d65816a2f8f44d115e
commit + e3644194d3747c9566be600b58e5cc6790d0bc6c
blob - bb79125082d73d0e0582a582c068c5b6fd716a7e
blob + 95de45a9235cc7b875f9ae926eff75b27e0b383b
--- kamiftp/rl.c
+++ kamiftp/rl.c
free(compl_state.entries[i]);
free(compl_state.entries);
- compl_state.len = 0;
- compl_state.size = 16;
- if ((compl_state.entries = calloc(16, sizeof(char *))) == NULL)
- compl_state.size = 0;
+ memset(&compl_state, 0, sizeof(compl_state));
}
static int
size_t newsz = compl_state.size * 1.5;
void *t;
+ if (newsz == 0)
+ newsz = 16;
+
+ /* one for the NULL entry at the end */
t = recallocarray(compl_state.entries, compl_state.size,
- newsz, sizeof(char *));
+ newsz + 1, sizeof(char *));
if (t == NULL)
return -1;
compl_state.entries = t;