Mercurial > hg
diff mcabber/src/screen.c @ 153:ae0844311710
[/trunk] Changeset 165 by mikael
* Do check on memory allocation for important data.
* Decrease scr_LogPrint buffer size to 1kb.
author | mikael |
---|---|
date | Sun, 01 May 2005 04:42:07 +0000 |
parents | b69c0b7a23e3 |
children | 8630b7cae87b |
line wrap: on
line diff
--- a/mcabber/src/screen.c Sun May 01 04:05:40 2005 +0000 +++ b/mcabber/src/screen.c Sun May 01 04:42:07 2005 +0000 @@ -184,7 +184,11 @@ int y; int lines; int cols; - window_entry_t *tmp = calloc(1, sizeof(window_entry_t)); + window_entry_t *tmp; + + do { + tmp = calloc(1, sizeof(window_entry_t)); + } while (!tmp); // Dimensions x = ROSTER_WIDTH; @@ -194,8 +198,8 @@ tmp->win = newwin(lines, cols, y, x); tmp->panel = new_panel(tmp->win); - tmp->name = (char *) calloc(1, 1024); - strncpy(tmp->name, title, 1024); + tmp->name = (char *) calloc(1, 96); + strncpy(tmp->name, title, 96); scr_clear_box(tmp->win, 0, 0, lines, cols, COLOR_GENERAL); if (!dont_show) { @@ -928,14 +932,16 @@ char *buffer; va_list ap; - buffer = (char *) calloc(1, 4096); + do { + buffer = (char *) calloc(1, 1024); + } while (!buffer); timestamp = time(NULL); strftime(buffer, 64, "[%H:%M:%S] ", localtime(×tamp)); wprintw(logWnd, "\n%s", buffer); va_start(ap, fmt); - vsnprintf(buffer, 4096, fmt, ap); + vsnprintf(buffer, 1024, fmt, ap); va_end(ap); wprintw(logWnd, "%s", buffer);