Mesa (master): d3d12: Fix memory leak if state is NULL.
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Thu Dec 24 22:01:03 UTC 2020
Module: Mesa
Branch: master
Commit: 28a9c9e573facb989736086383c2ba2ae882c4be
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=28a9c9e573facb989736086383c2ba2ae882c4be
Author: Vinson Lee <vlee at freedesktop.org>
Date: Sun Dec 20 15:44:20 2020 -0800
d3d12: Fix memory leak if state is NULL.
Fix defect reported by Coverity Scan.
Resource leak (RESOURCE_LEAK)
leaked_storage: Variable ss going out of scope leaks the storage it points to.
Fixes: 2ea15cd661c ("d3d12: introduce d3d12 gallium driver")
Signed-off-by: Vinson Lee <vlee at freedesktop.org>
Reviewed-by: Jesse Natalie <jenatali at microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8179>
---
src/gallium/drivers/d3d12/d3d12_context.cpp | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/gallium/drivers/d3d12/d3d12_context.cpp b/src/gallium/drivers/d3d12/d3d12_context.cpp
index cce9ffd6322..7f4c97e0b8b 100644
--- a/src/gallium/drivers/d3d12/d3d12_context.cpp
+++ b/src/gallium/drivers/d3d12/d3d12_context.cpp
@@ -619,11 +619,12 @@ d3d12_create_sampler_state(struct pipe_context *pctx,
{
struct d3d12_context *ctx = d3d12_context(pctx);
struct d3d12_screen *screen = d3d12_screen(pctx->screen);
- struct d3d12_sampler_state *ss = CALLOC_STRUCT(d3d12_sampler_state);
+ struct d3d12_sampler_state *ss;
D3D12_SAMPLER_DESC desc = {};
if (!state)
return NULL;
+ ss = CALLOC_STRUCT(d3d12_sampler_state);
ss->filter = (pipe_tex_filter)state->min_img_filter;
ss->wrap_r = (pipe_tex_wrap)state->wrap_r;
ss->wrap_s = (pipe_tex_wrap)state->wrap_s;
More information about the mesa-commit
mailing list