From c7520629b0d655bde1db9cbe0012f91502265b5d Mon Sep 17 00:00:00 2001 From: James Bursa Date: Wed, 16 Jul 2003 17:38:46 +0000 Subject: [project @ 2003-07-16 17:38:46 by bursa] Make fetchcache return 0 on failure to parse URL. svn path=/import/netsurf/; revision=225 --- content/content.c | 12 +++++++++--- content/fetch.c | 5 ++++- content/fetchcache.c | 6 ++++++ 3 files changed, 19 insertions(+), 4 deletions(-) (limited to 'content') diff --git a/content/content.c b/content/content.c index 2c7f5d00e..253caea16 100644 --- a/content/content.c +++ b/content/content.c @@ -121,6 +121,7 @@ struct content * content_create(char *url) c->url = xstrdup(url); c->type = CONTENT_UNKNOWN; c->status = CONTENT_STATUS_TYPE_UNKNOWN; + c->cache = 0; c->size = sizeof(struct content); c->fetch = 0; strcpy(c->status_message, "Loading"); @@ -178,6 +179,8 @@ void content_convert(struct content *c, unsigned long width, unsigned long heigh if (handler_map[c->type].convert(c, width, height)) { /* convert failed, destroy content */ content_broadcast(c, CONTENT_MSG_ERROR, "Conversion failed"); + if (c->cache) + cache_destroy(c); content_destroy(c); return; } @@ -305,10 +308,13 @@ void content_remove_user(struct content *c, if (c->fetch != 0) fetch_abort(c->fetch); if (c->status < CONTENT_STATUS_READY) { - cache_destroy(c); + if (c->cache) + cache_destroy(c); content_destroy(c); - } else - cache_freeable(c); + } else { + if (c->cache) + cache_freeable(c); + } } } diff --git a/content/fetch.c b/content/fetch.c index 3b057c266..330f68d3b 100644 --- a/content/fetch.c +++ b/content/fetch.c @@ -119,7 +119,10 @@ struct fetch * fetch_start(char *url, char *referer, LOG(("fetch %p, url '%s'", fetch, url)); uri = xmlParseURI(url); - assert(uri != 0); + if (uri == 0) { + LOG(("warning: failed to parse url")); + return 0; + } /* construct a new fetch structure */ fetch->start_time = time(0); diff --git a/content/fetchcache.c b/content/fetchcache.c index 844111376..99686efe0 100644 --- a/content/fetchcache.c +++ b/content/fetchcache.c @@ -46,6 +46,12 @@ struct content * fetchcache(const char *url0, char *referer, c->width = width; c->height = height; c->fetch = fetch_start(url, referer, fetchcache_callback, c); + if (c->fetch == 0) { + LOG(("warning: fetch_start failed")); + cache_destroy(c); + content_destroy(c); + return 0; + } return c; } -- cgit v1.2.3