- fix buffer size reallocation

- fix history crash
This commit is contained in:
Adam Olsen 2001-09-20 07:34:27 +00:00
parent 0977b555f3
commit 388c102a57
2 changed files with 3 additions and 1 deletions

View file

@ -121,6 +121,8 @@ Con_ProcessInputLine (inputline_t *il, int ch)
case K_UP: case K_UP:
do { do {
il->history_line = (il->history_line - 1) % il->num_lines; il->history_line = (il->history_line - 1) % il->num_lines;
if (il->history_line < 0)
il->history_line = il->num_lines - 1;
} while (il->history_line != il->edit_line } while (il->history_line != il->edit_line
&& !il->lines[il->history_line][1]); && !il->lines[il->history_line][1]);
if (il->history_line == il->edit_line) if (il->history_line == il->edit_line)

View file

@ -184,7 +184,7 @@ C_Print (const char *fmt, va_list args)
size = vsnprintf (buffer, buffer_size, fmt, args); size = vsnprintf (buffer, buffer_size, fmt, args);
if (size + 1 > buffer_size) { if (size + 1 > buffer_size) {
buffer_size = (size + 1 + 1024) % 1024; // 1k multiples buffer_size = ((size + 1 + 1024) / 1024) * 1024; // 1k multiples
buffer = realloc (buffer, buffer_size); buffer = realloc (buffer, buffer_size);
if (!buffer) if (!buffer)
Sys_Error ("console: could not allocate %d bytes\n", Sys_Error ("console: could not allocate %d bytes\n",