From a221fa721360e4aef1488eddc4891e10c26cb73d Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Wed, 29 Oct 2014 22:14:48 +0000 Subject: Ensure browser window creation returns errors from common initialisation. The browser window common initialisation code returns error codes which were being ignored. The errors were additionally being reported via warn_user in inappropriate places within browser history construction. --- desktop/browser.c | 7 ++++++- desktop/browser_history.c | 9 ++++----- 2 files changed, 10 insertions(+), 6 deletions(-) (limited to 'desktop') diff --git a/desktop/browser.c b/desktop/browser.c index e6fc2f794..a13c2948e 100644 --- a/desktop/browser.c +++ b/desktop/browser.c @@ -752,6 +752,7 @@ nserror browser_window_create(enum browser_window_create_flags flags, { gui_window_create_flags gw_flags = GW_CREATE_NONE; struct browser_window *ret; + nserror err; /* Check parameters */ if (flags & BW_CREATE_CLONE) { @@ -778,7 +779,11 @@ nserror browser_window_create(enum browser_window_create_flags flags, NULL); /* Initialise common parts */ - browser_window_initialise_common(flags, ret, existing); + err = browser_window_initialise_common(flags, ret, existing); + if (err != NSERROR_OK) { + browser_window_destroy(ret); + return err; + } /* window characteristics */ ret->browser_window_type = BROWSER_WINDOW_NORMAL; diff --git a/desktop/browser_history.c b/desktop/browser_history.c index 445c0ee06..309bcb2b4 100644 --- a/desktop/browser_history.c +++ b/desktop/browser_history.c @@ -416,9 +416,9 @@ static bool browser_window_history__enumerate_entry( /** * Create a new history tree for a browser window window. * - * \param bw browser window to create history for. + * \param bw browser window to create history for. * - * \return NSERROR_OK or appropriate error otherwise + * \return NSERROR_OK or appropriate error otherwise */ nserror browser_window_history_create(struct browser_window *bw) @@ -428,10 +428,10 @@ nserror browser_window_history_create(struct browser_window *bw) bw->history = NULL; history = calloc(1, sizeof *history); - if (!history) { - warn_user("NoMemory", 0); + if (history == NULL) { return NSERROR_NOMEM; } + history->width = RIGHT_MARGIN / 2; history->height = BOTTOM_MARGIN / 2; @@ -473,7 +473,6 @@ nserror browser_window_history_clone(const struct browser_window *existing, new_history->start); if (!new_history->start) { LOG(("Insufficient memory to clone history")); - warn_user("NoMemory", 0); browser_window_history_destroy(clone); clone->history = NULL; return NSERROR_NOMEM; -- cgit v1.2.3