summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorChia-I Wu <[email protected]>2014-09-14 00:15:20 +0800
committerChia-I Wu <[email protected]>2014-09-14 00:30:33 +0800
commita32f48361af58caf27bea8359bd5faed29fbf5e9 (patch)
treee33748d77389645a06e5f351bcaedc47eb35a86a /src
parent8fcf1b1f90901d59bf4cca0e04aa84d2c55de9ed (diff)
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 <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/gallium/drivers/ilo/ilo_builder_3d_top.h5
1 files changed, 2 insertions, 3 deletions
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));
}