From 89a02c3a8fa8b386224e531118c82a6a76332229 Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Tue, 8 Jul 2014 13:25:54 +0100 Subject: when walking the css imports ensure the content is present before dereferencing it css import entries may not have a valid content if the resource failed to load or was unsuitable in some otehr way. The save_complete iterator did not cope with this. fixes #2166 --- css/css.c | 4 ++-- desktop/save_complete.c | 7 +++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/css/css.c b/css/css.c index 94c0be3be..9dc6e8cba 100644 --- a/css/css.c +++ b/css/css.c @@ -575,14 +575,14 @@ css_error nscss_handle_import(void *pw, css_stylesheet *parent, /* Create content */ c->imports[c->import_count].media = media; - /* TODO: Why aren't we getting a relative url part, to join? */ + /** \todo Why aren't we getting a relative url part, to join? */ nerror = nsurl_create(lwc_string_data(url), &ns_url); if (nerror != NSERROR_OK) { free(ctx); return CSS_NOMEM; } - /* TODO: Constructing nsurl for referer here is silly, avoid */ + /** \todo Constructing nsurl for referer here is silly, avoid */ nerror = nsurl_create(referer, &ns_ref); if (nerror != NSERROR_OK) { nsurl_unref(ns_url); diff --git a/desktop/save_complete.c b/desktop/save_complete.c index f6d3e7664..71187eb10 100644 --- a/desktop/save_complete.c +++ b/desktop/save_complete.c @@ -355,8 +355,11 @@ static bool save_complete_save_imported_sheets(save_complete_ctx *ctx, uint32_t i; for (i = 0; i < import_count; i++) { - if (save_complete_save_stylesheet(ctx, imports[i].c) == false) - return false; + /* treat a valid content as a stylesheet to save */ + if ((imports[i].c != NULL) && + (save_complete_save_stylesheet(ctx, imports[i].c) == false)) { + return false; + } } return true; -- cgit v1.2.3