From 2b8adb0c8af3c9e49cfb90be769269359b045a00 Mon Sep 17 00:00:00 2001 From: Daniel Silverstone Date: Thu, 8 Apr 2010 13:39:07 +0000 Subject: Move the removal of the retrieval context to prevent a re-entrancy race causing double-release of llcache handles svn path=/trunk/netsurf/; revision=10307 --- content/hlcache.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'content/hlcache.c') diff --git a/content/hlcache.c b/content/hlcache.c index c78a91599..944022b4a 100644 --- a/content/hlcache.c +++ b/content/hlcache.c @@ -273,12 +273,17 @@ nserror hlcache_llcache_callback(llcache_handle *handle, case LLCACHE_EVENT_HAD_HEADERS: { content_type type; - + + /* Unlink the context to prevent recursion */ + RING_REMOVE(hlcache_retrieval_ctx_ring, ctx); + if (hlcache_type_is_acceptable(handle, ctx->accepted_types, &type)) { error = hlcache_find_content(ctx); - if (error != NSERROR_OK) + if (error != NSERROR_OK) { + free(ctx); return error; + } } else if (type == CONTENT_OTHER && ctx->flags & HLCACHE_RETRIEVE_MAY_DOWNLOAD) { /* Unknown type, and we can download, so convert */ @@ -310,7 +315,6 @@ nserror hlcache_llcache_callback(llcache_handle *handle, } /* No longer require retrieval context */ - RING_REMOVE(hlcache_retrieval_ctx_ring, ctx); free(ctx); } break; -- cgit v1.2.3