From: Chia-I Wu Date: Sat, 13 Sep 2014 16:15:20 +0000 (+0800) Subject: ilo: trust vertex element count more X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=a32f48361af58caf27bea8359bd5faed29fbf5e9;p=mesa.git ilo: trust vertex element count more We might run into ve->count == 0 and last_velement_edgeflag == true in gen6_3DSTATE_VERTEX_ELEMENTS() when the state tracker sets an invalid combination of VS and VE (does not seem to happen with st/mesa). Do not assume ve->count is positive when last_velement_edgeflag is true. Reported by Coverity. Signed-off-by: Chia-I Wu --- diff --git a/src/gallium/drivers/ilo/ilo_builder_3d_top.h b/src/gallium/drivers/ilo/ilo_builder_3d_top.h index e742f63d698..4e3dcff3c03 100644 --- a/src/gallium/drivers/ilo/ilo_builder_3d_top.h +++ b/src/gallium/drivers/ilo/ilo_builder_3d_top.h @@ -537,7 +537,7 @@ gen6_3DSTATE_VERTEX_ELEMENTS(struct ilo_builder *builder, dw += 2; } - if (last_velement_edgeflag) { + if (last_velement_edgeflag && ve->count) { struct ilo_ve_cso edgeflag; for (i = 0; i < ve->count - 1; i++) @@ -546,8 +546,7 @@ gen6_3DSTATE_VERTEX_ELEMENTS(struct ilo_builder *builder, edgeflag = ve->cso[i]; ve_set_cso_edgeflag(builder->dev, &edgeflag); memcpy(&dw[2 * i], edgeflag.payload, sizeof(edgeflag.payload)); - } - else { + } else { for (i = 0; i < ve->count; i++) memcpy(&dw[2 * i], ve->cso[i].payload, sizeof(ve->cso[i].payload)); }