From a10c4d3a7befe87d183d71a5b450c36980fac31c Mon Sep 17 00:00:00 2001 From: John Mark Bell Date: Thu, 16 Sep 2010 22:46:40 +0000 Subject: [PATCH] Fix crash on receipt of a 304 response: it turns out that FETCH_HEADER may be called before any decision about how to process the response is made. Move FETCH_HEADER handler to start of switch statement to reflect this. svn path=/trunk/netsurf/; revision=10792 --- content/llcache.c | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/content/llcache.c b/content/llcache.c index c56db13e3..c01a91fe0 100644 --- a/content/llcache.c +++ b/content/llcache.c @@ -1650,6 +1650,13 @@ void llcache_fetch_callback(fetch_msg msg, void *p, const void *data, #endif switch (msg) { + case FETCH_HEADER: + /* Received a fetch header */ + object->fetch.state = LLCACHE_FETCH_HEADERS; + + error = llcache_fetch_process_header(object, data, size); + break; + /* 3xx responses */ case FETCH_REDIRECT: /* Request resulted in a redirect */ @@ -1668,18 +1675,6 @@ void llcache_fetch_callback(fetch_msg msg, void *p, const void *data, break; /* Normal 2xx state machine */ - case FETCH_HEADER: - /* Received a fetch header */ - object->fetch.state = LLCACHE_FETCH_HEADERS; - - /* Release candidate, if any */ - if (object->candidate != NULL) { - object->candidate->candidate_count--; - object->candidate = NULL; - } - - error = llcache_fetch_process_header(object, data, size); - break; case FETCH_DATA: /* Received some data */ if (object->fetch.state != LLCACHE_FETCH_DATA) { @@ -1704,6 +1699,12 @@ void llcache_fetch_callback(fetch_msg msg, void *p, const void *data, /* Invalidate cache control data */ llcache_invalidate_cache_control_data(object); } + + /* Release candidate, if any */ + if (object->candidate != NULL) { + object->candidate->candidate_count--; + object->candidate = NULL; + } } object->fetch.state = LLCACHE_FETCH_DATA;