anv: null check for buffer before reading size
authorTapani Pälli <tapani.palli@intel.com>
Tue, 18 Aug 2020 12:16:37 +0000 (15:16 +0300)
committerTapani Pälli <tapani.palli@intel.com>
Thu, 20 Aug 2020 05:33:59 +0000 (08:33 +0300)
v2: move assignment under existing check (Nanley)

Fixes: b9a05447a19 ("anv: dynamic vertex input binding stride and size support")
Signed-off-by: Tapani Pälli <tapani.palli@intel.com>
Reviewed-by: Nanley Chery <nanley.g.chery@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6369>

src/intel/vulkan/genX_cmd_buffer.c

index 7afaeca366b23df5b610e79652f172ec88a5f418..4522f5d2aef0b98198dcb63f9f09a27370fe50ec 100644 (file)
@@ -3344,13 +3344,13 @@ genX(cmd_buffer_flush_state)(struct anv_cmd_buffer *cmd_buffer)
          bool dynamic_stride = cmd_buffer->state.gfx.dynamic.dyn_vbo_stride;
          bool dynamic_size = cmd_buffer->state.gfx.dynamic.dyn_vbo_size;
 
-         uint32_t stride = dynamic_stride ?
-            cmd_buffer->state.vertex_bindings[vb].stride : pipeline->vb[vb].stride;
-         uint32_t size = dynamic_size ?
-            cmd_buffer->state.vertex_bindings[vb].size : buffer->size;
-
          struct GENX(VERTEX_BUFFER_STATE) state;
          if (buffer) {
+            uint32_t stride = dynamic_stride ?
+               cmd_buffer->state.vertex_bindings[vb].stride : pipeline->vb[vb].stride;
+            uint32_t size = dynamic_size ?
+               cmd_buffer->state.vertex_bindings[vb].size : buffer->size;
+
             state = (struct GENX(VERTEX_BUFFER_STATE)) {
                .VertexBufferIndex = vb,