From 8c3e9b882be5b44e6708b997320073d8b78b7a8d Mon Sep 17 00:00:00 2001 From: John Mark Bell Date: Thu, 29 Jun 2006 22:04:56 +0000 Subject: Fix crash when url_* fails svn path=/trunk/netsurf/; revision=2678 --- content/fetch.c | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) (limited to 'content') diff --git a/content/fetch.c b/content/fetch.c index 44d326f92..19fafccbe 100644 --- a/content/fetch.c +++ b/content/fetch.c @@ -315,24 +315,32 @@ struct fetch * fetch_start(char *url, char *referer, return 0; res = url_host(url, &host); - /* we only fail memory exhaustion */ - if (res == URL_FUNC_NOMEM) - goto failed; - if (!host) + if (res != URL_FUNC_OK) { + /* we only fail memory exhaustion */ + if (res == URL_FUNC_NOMEM) + goto failed; + host = strdup(""); - if (!host) - goto failed; + if (!host) + goto failed; + } res = url_scheme(url, &ref1); - /* we only fail memory exhaustion */ - if (res == URL_FUNC_NOMEM) - goto failed; - - if (referer) { - res = url_scheme(referer, &ref2); + if (res != URL_FUNC_OK) { /* we only fail memory exhaustion */ if (res == URL_FUNC_NOMEM) goto failed; + ref1 = NULL; + } + + if (referer) { + res = url_scheme(referer, &ref2); + if (res != URL_FUNC_OK) { + /* we only fail memory exhaustion */ + if (res == URL_FUNC_NOMEM) + goto failed; + ref2 = NULL; + } } LOG(("fetch %p, url '%s'", fetch, url)); -- cgit v1.2.3