summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVincent Sanders <vince@kyllikki.org>2017-06-12 21:58:43 (GMT)
committer Vincent Sanders <vince@kyllikki.org>2017-06-12 21:58:43 (GMT)
commit2b2bbbe76502b6cb528752a2dad89d3f1f6c6409 (patch)
tree2da60087444b6ea7102387d000e4fc87689c6113
parentc4c2c22e87ba5018d0a90abfc01af51da996e3b5 (diff)
downloadnetsurf-2b2bbbe76502b6cb528752a2dad89d3f1f6c6409.tar.gz
netsurf-2b2bbbe76502b6cb528752a2dad89d3f1f6c6409.tar.bz2
fix resource leak on error in local history initialisation
-rw-r--r--desktop/local_history.c29
1 files changed, 15 insertions, 14 deletions
diff --git a/desktop/local_history.c b/desktop/local_history.c
index fe7f4a9..01222e2 100644
--- a/desktop/local_history.c
+++ b/desktop/local_history.c
@@ -259,24 +259,15 @@ find_entry_position(struct history_entry *entry, int x, int y)
/* exported interface documented in desktop/local_history.h */
-nserror local_history_init(struct core_window_callback_table *cw_t,
- void *core_window_handle,
- struct browser_window *bw,
- struct local_history_session **session)
+nserror
+local_history_init(struct core_window_callback_table *cw_t,
+ void *core_window_handle,
+ struct browser_window *bw,
+ struct local_history_session **session)
{
nserror res;
struct local_history_session *nses;
- nses = calloc(1, sizeof(struct local_history_session));
- if (nses == NULL) {
- return NSERROR_NOMEM;
- }
-
- nses->cw_t = cw_t;
- nses->core_window_handle = core_window_handle;
-
- local_history_set(nses, bw);
-
res = ns_system_colour_char("Window", &pstyle_bg.fill_colour);
if (res != NSERROR_OK) {
return res;
@@ -297,8 +288,18 @@ nserror local_history_init(struct core_window_callback_table *cw_t,
}
pfstyle_node_sel.foreground = pstyle_rect_sel.stroke_colour;
+ nses = calloc(1, sizeof(struct local_history_session));
+ if (nses == NULL) {
+ return NSERROR_NOMEM;
+ }
+
+ nses->cw_t = cw_t;
+ nses->core_window_handle = core_window_handle;
+
+ local_history_set(nses, bw);
*session = nses;
+
return NSERROR_OK;
}