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
This commit is contained in:
Daniel Silverstone 2010-04-08 13:39:07 +00:00
parent 8f1dec6f1d
commit 2b8adb0c8a

View File

@ -273,12 +273,17 @@ nserror hlcache_llcache_callback(llcache_handle *handle,
case LLCACHE_EVENT_HAD_HEADERS: case LLCACHE_EVENT_HAD_HEADERS:
{ {
content_type type; content_type type;
/* Unlink the context to prevent recursion */
RING_REMOVE(hlcache_retrieval_ctx_ring, ctx);
if (hlcache_type_is_acceptable(handle, if (hlcache_type_is_acceptable(handle,
ctx->accepted_types, &type)) { ctx->accepted_types, &type)) {
error = hlcache_find_content(ctx); error = hlcache_find_content(ctx);
if (error != NSERROR_OK) if (error != NSERROR_OK) {
free(ctx);
return error; return error;
}
} else if (type == CONTENT_OTHER && } else if (type == CONTENT_OTHER &&
ctx->flags & HLCACHE_RETRIEVE_MAY_DOWNLOAD) { ctx->flags & HLCACHE_RETRIEVE_MAY_DOWNLOAD) {
/* Unknown type, and we can download, so convert */ /* Unknown type, and we can download, so convert */
@ -310,7 +315,6 @@ nserror hlcache_llcache_callback(llcache_handle *handle,
} }
/* No longer require retrieval context */ /* No longer require retrieval context */
RING_REMOVE(hlcache_retrieval_ctx_ring, ctx);
free(ctx); free(ctx);
} }
break; break;