From bc0571b9dc2719ac8218f9523627d55ff1016b04 Mon Sep 17 00:00:00 2001 From: Michael Drake Date: Thu, 29 Aug 2013 13:08:04 +0100 Subject: Better handling of added entry titles. --- desktop/hotlist.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/desktop/hotlist.c b/desktop/hotlist.c index 2eb723584..79e1061d2 100644 --- a/desktop/hotlist.c +++ b/desktop/hotlist.c @@ -296,9 +296,9 @@ static nserror hotlist_add_folder_internal( if (title == NULL) { /* TODO: use messages */ title = strdup("New folder"); - } - if (title == NULL) { - return NSERROR_NOMEM; + if (title == NULL) { + return NSERROR_NOMEM; + } } /* Create the title field */ @@ -1330,13 +1330,21 @@ nserror hotlist_add_entry(nsurl *url, const char *title, bool at_y, int y) nsurl_ref(url); } + if (title != NULL) { + title = strdup(title); + if (title == NULL) { + nsurl_ref(url); + return NSERROR_NOMEM; + } + } + err = treeview_get_relation(hl_ctx.tree, &relation, &rel, at_y, y); if (err != NSERROR_OK) { nsurl_unref(url); return err; } - err = hotlist_add_entry_internal(url, NULL, NULL, + err = hotlist_add_entry_internal(url, title, NULL, relation, rel, &entry); if (err != NSERROR_OK) { nsurl_unref(url); -- cgit v1.2.3