From e68f20d1c0612877afefcc581237bb5c70c8dbe6 Mon Sep 17 00:00:00 2001 From: Richard Wilson Date: Tue, 4 Jul 2006 14:07:07 +0000 Subject: Stop lack of history entries from writing to invalid pointers (fix 1479657) svn path=/trunk/netsurf/; revision=2708 --- desktop/history_core.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'desktop/history_core.c') diff --git a/desktop/history_core.c b/desktop/history_core.c index 2a0b366ca..e53bdf314 100644 --- a/desktop/history_core.c +++ b/desktop/history_core.c @@ -87,15 +87,13 @@ struct history *history_create(void) { struct history *history; - history = malloc(sizeof *history); + history = calloc(1, sizeof *history); if (!history) { warn_user("NoMemory", 0); return 0; } - - history->start = 0; - history->current = 0; - + history->width = RIGHT_MARGIN / 2; + history->height = BOTTOM_MARGIN / 2; return history; } @@ -440,8 +438,12 @@ void history_layout(struct history *history) bool shuffle = tp->tm_mon == 3 && tp->tm_mday == 1; history->width = 0; - history->height = history_layout_subtree(history, history->start, - RIGHT_MARGIN / 2, BOTTOM_MARGIN / 2, shuffle); + if (history->start) + history->height = history_layout_subtree(history, + history->start, RIGHT_MARGIN / 2, BOTTOM_MARGIN / 2, + shuffle); + else + history->height = 0; if (shuffle) { history->width = 600 + WIDTH; history->height = 400 + HEIGHT; @@ -470,7 +472,7 @@ int history_layout_subtree(struct history *history, if (history->width < x + WIDTH) history->width = x + WIDTH; - + if (!entry->forward) { entry->x = x; entry->y = y; -- cgit v1.2.3