From 2b5f9602b7786483e8bd47f04c33df8635cbb13a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20=C5=9Alusarz?= Date: Fri, 19 Mar 2021 11:31:30 +0100 Subject: [PATCH] intel/aub_viewer: catch invalid sampler state pointer MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Marcin Ĺšlusarz Reviewed-by: Lionel Landwerlin Part-of: --- src/intel/tools/aubinator_viewer_decoder.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/intel/tools/aubinator_viewer_decoder.cpp b/src/intel/tools/aubinator_viewer_decoder.cpp index 3844300eb8a..60b76c24fa6 100644 --- a/src/intel/tools/aubinator_viewer_decoder.cpp +++ b/src/intel/tools/aubinator_viewer_decoder.cpp @@ -270,14 +270,21 @@ dump_samplers(struct aub_viewer_decode_ctx *ctx, uint32_t offset, int count) return; } + const unsigned sampler_state_size = strct->dw_length * 4; + + if (count * sampler_state_size >= bo.size) { + ImGui::TextColored(ctx->cfg->missing_color, "sampler state ends after bo ends"); + return; + } + for (int i = 0; i < count; i++) { if (ImGui::TreeNodeEx(state_map, ImGuiTreeNodeFlags_Framed, "sampler state %d", i)) { aub_viewer_print_group(ctx, strct, state_addr, state_map); ImGui::TreePop(); } - state_addr += 16; - state_map += 16; + state_addr += sampler_state_size; + state_map += sampler_state_size; } }