From 7b4bb33ce4ded713eb1736c2ee39c173809e916f Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Wed, 4 Feb 2015 14:21:08 +1000 Subject: [PATCH] renderer: protect attach/detach resource against illegal inputs make sure we find the context and resource for attach/detach. --- src/vrend_renderer.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/vrend_renderer.c b/src/vrend_renderer.c index 9939262..ab572d0 100644 --- a/src/vrend_renderer.c +++ b/src/vrend_renderer.c @@ -5357,7 +5357,14 @@ void vrend_renderer_get_rect(int res_handle, struct iovec *iov, unsigned int num void vrend_renderer_attach_res_ctx(int ctx_id, int resource_id) { struct vrend_context *ctx = vrend_lookup_renderer_ctx(ctx_id); - struct vrend_resource *res = vrend_resource_lookup(resource_id, 0); + struct vrend_resource *res; + + if (!ctx) + return; + + res = vrend_resource_lookup(resource_id, 0); + if (!res) + return; vrend_object_insert_nofree(ctx->res_hash, res, sizeof(*res), resource_id, 1, false); } @@ -5365,8 +5372,11 @@ void vrend_renderer_attach_res_ctx(int ctx_id, int resource_id) void vrend_renderer_detach_res_ctx(int ctx_id, int res_handle) { struct vrend_context *ctx = vrend_lookup_renderer_ctx(ctx_id); - struct vrend_resource *res = vrend_object_lookup(ctx->res_hash, res_handle, 1); + struct vrend_resource *res; + if (!ctx) + return; + res = vrend_object_lookup(ctx->res_hash, res_handle, 1); if (!res) return;