summaryrefslogtreecommitdiffstats
path: root/src/gallium
diff options
context:
space:
mode:
authorEmil Velikov <emil.l.velikov@gmail.com>2014-01-16 16:35:27 +0000
committerEmil Velikov <emil.l.velikov@gmail.com>2014-01-18 19:17:15 +0000
commit5e130f237173a9fc241d7df4d989d046206ba3b2 (patch)
tree6d1918ef09a3b446180b976d7e101d83c9c05484 /src/gallium
parent12e744abbb9fd8cb07a12954aaa7127521d5af0a (diff)
downloadexternal_mesa3d-5e130f237173a9fc241d7df4d989d046206ba3b2.zip
external_mesa3d-5e130f237173a9fc241d7df4d989d046206ba3b2.tar.gz
external_mesa3d-5e130f237173a9fc241d7df4d989d046206ba3b2.tar.bz2
nv50: assert before trying to out-of-bounds access constbuf
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com> Reviewed-by: Ilia Mirkin <imirkin@alum.mit.edu>
Diffstat (limited to 'src/gallium')
-rw-r--r--src/gallium/drivers/nouveau/nv50/nv50_context.c1
-rw-r--r--src/gallium/drivers/nouveau/nv50/nv50_shader_state.c2
-rw-r--r--src/gallium/drivers/nouveau/nv50/nv50_state.c1
3 files changed, 4 insertions, 0 deletions
diff --git a/src/gallium/drivers/nouveau/nv50/nv50_context.c b/src/gallium/drivers/nouveau/nv50/nv50_context.c
index bd00b50..9ea425e 100644
--- a/src/gallium/drivers/nouveau/nv50/nv50_context.c
+++ b/src/gallium/drivers/nouveau/nv50/nv50_context.c
@@ -180,6 +180,7 @@ nv50_invalidate_resource_storage(struct nouveau_context *ctx,
if (res->bind & PIPE_BIND_CONSTANT_BUFFER) {
for (s = 0; s < 3; ++s) {
+ assert(nv50->num_vtxbufs <= NV50_MAX_PIPE_CONSTBUFS);
for (i = 0; i < nv50->num_vtxbufs; ++i) {
if (!nv50->constbuf[s][i].user &&
nv50->constbuf[s][i].u.buf == res) {
diff --git a/src/gallium/drivers/nouveau/nv50/nv50_shader_state.c b/src/gallium/drivers/nouveau/nv50/nv50_shader_state.c
index 9144fc4..c44d208 100644
--- a/src/gallium/drivers/nouveau/nv50/nv50_shader_state.c
+++ b/src/gallium/drivers/nouveau/nv50/nv50_shader_state.c
@@ -47,6 +47,8 @@ nv50_constbufs_validate(struct nv50_context *nv50)
while (nv50->constbuf_dirty[s]) {
const int i = ffs(nv50->constbuf_dirty[s]) - 1;
+
+ assert(i < NV50_MAX_PIPE_CONSTBUFS);
nv50->constbuf_dirty[s] &= ~(1 << i);
if (nv50->constbuf[s][i].user) {
diff --git a/src/gallium/drivers/nouveau/nv50/nv50_state.c b/src/gallium/drivers/nouveau/nv50/nv50_state.c
index 87dd07f..6b5a288 100644
--- a/src/gallium/drivers/nouveau/nv50/nv50_state.c
+++ b/src/gallium/drivers/nouveau/nv50/nv50_state.c
@@ -786,6 +786,7 @@ nv50_set_constant_buffer(struct pipe_context *pipe, uint shader, uint index,
if (shader == PIPE_SHADER_COMPUTE)
return;
+ assert(i < NV50_MAX_PIPE_CONSTBUFS);
if (nv50->constbuf[s][i].user)
nv50->constbuf[s][i].u.buf = NULL;
else