*** ../bash-4.4/lib/readline/history.c 2015-12-28 13:50:31.000000000 -0500 --- lib/readline/history.c 2016-09-30 14:28:40.000000000 -0400 *************** *** 417,426 **** { HIST_ENTRY *hent; ! size_t newlen, curlen; char *newline; hent = the_history[which]; curlen = strlen (hent->line); ! newlen = curlen + strlen (line) + 2; newline = realloc (hent->line, newlen); if (newline) --- 421,441 ---- { HIST_ENTRY *hent; ! size_t newlen, curlen, minlen; char *newline; hent = the_history[which]; curlen = strlen (hent->line); ! minlen = curlen + strlen (line) + 2; /* min space needed */ ! if (curlen > 256) /* XXX - for now */ ! { ! newlen = 512; /* now realloc in powers of 2 */ ! /* we recalcluate every time; the operations are cheap */ ! while (newlen < minlen) ! newlen <<= 1; ! } ! else ! newlen = minlen; ! /* Assume that realloc returns the same pointer and doesn't try a new ! alloc/copy if the new size is the same as the one last passed. */ newline = realloc (hent->line, newlen); if (newline)