diff options
author | Michael Drake <michael.drake@codethink.co.uk> | 2017-04-28 12:02:48 +0100 |
---|---|---|
committer | Michael Drake <michael.drake@codethink.co.uk> | 2017-04-28 12:02:48 +0100 |
commit | 06baaa9f7c037d2aa9d9c67e0b9b07724372e0f0 (patch) | |
tree | f941a1385526f15a2f17890d1b3f0e51841b8baf /desktop/hotlist.c | |
parent | 6c726473eff8a352d51e3931356347384bd8686a (diff) | |
download | netsurf-06baaa9f7c037d2aa9d9c67e0b9b07724372e0f0.tar.gz netsurf-06baaa9f7c037d2aa9d9c67e0b9b07724372e0f0.tar.bz2 |
Core hotlist: A NULL save_path makes the hotlist read-only.
Diffstat (limited to 'desktop/hotlist.c')
-rw-r--r-- | desktop/hotlist.c | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/desktop/hotlist.c b/desktop/hotlist.c index 3e2fcedd5..0f5be77c9 100644 --- a/desktop/hotlist.c +++ b/desktop/hotlist.c @@ -107,7 +107,7 @@ static nserror hotlist_get_temp_path(const char *path, char **temp_path) /* Save the hotlist to to a file at the given path * - * \param path Path to save hostlist file to. + * \param path Path to save hotlist file to. NULL path is a no-op. * \return NSERROR_OK on success, or appropriate error otherwise */ static nserror hotlist_save(const char *path) @@ -115,6 +115,11 @@ static nserror hotlist_save(const char *path) nserror res = NSERROR_OK; char *temp_path; + /* NULL path is a no-op. */ + if (path == NULL) { + return NSERROR_OK; + } + /* Get path to export to */ res = hotlist_get_temp_path(path, &temp_path); if (res != NSERROR_OK) { @@ -163,7 +168,7 @@ static void hotlist_schedule_save_cb(void *p) */ static nserror hotlist_schedule_save(void) { - if (hl_ctx.save_scheduled == false) { + if (hl_ctx.save_scheduled == false && hl_ctx.save_path != NULL) { nserror err = guit->misc->schedule(10 * 1000, hotlist_schedule_save_cb, NULL); if (err != NSERROR_OK) { @@ -1285,9 +1290,13 @@ nserror hotlist_init( hl_ctx.default_folder = NULL; /* Store the save path */ - hl_ctx.save_path = strdup(save_path); - if (hl_ctx.save_path == NULL) { - return NSERROR_NOMEM; + if (save_path != NULL) { + hl_ctx.save_path = strdup(save_path); + if (hl_ctx.save_path == NULL) { + return NSERROR_NOMEM; + } + } else { + hl_ctx.save_path = NULL; } /* Init. hotlist treeview entry fields */ |