diff options
author | Vinson Lee <vlee@freedesktop.org> | 2020-12-20 15:44:20 -0800 |
---|---|---|
committer | Marge Bot <eric+marge@anholt.net> | 2020-12-24 21:52:15 +0000 |
commit | 28a9c9e573facb989736086383c2ba2ae882c4be (patch) | |
tree | 65352f9172cde6a4c34f1fc0eba28a87aa481019 | |
parent | 671e1571d9fc98d94b37c353e638518919244d63 (diff) |
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@freedesktop.org>
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8179>
-rw-r--r-- | src/gallium/drivers/d3d12/d3d12_context.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
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; |