shader: add a check for number of imm and ubo

I think UBO limit is 32, but IMM is not, so we better had some checks to
avoid overflow
macos/master
Marc-André Lureau 10 years ago committed by Dave Airlie
parent 5f3f9459d6
commit fc7e0ef0fb
  1. 10
      src/vrend_shader.c

@ -24,6 +24,7 @@
#include "tgsi/tgsi_info.h"
#include "tgsi/tgsi_iterate.h"
#include "util/u_memory.h"
#include <string.h>
#include <stdio.h>
#include <math.h>
@ -531,6 +532,10 @@ iter_declaration(struct tgsi_iterate_context *iter,
break;
case TGSI_FILE_CONSTANT:
if (decl->Declaration.Dimension) {
if (ctx->num_ubo >= ARRAY_SIZE(ctx->ubo_idx)) {
fprintf(stderr, "Number of uniforms exceeded, max is %lu\n", ARRAY_SIZE(ctx->ubo_idx));
return FALSE;
}
ctx->ubo_idx[ctx->num_ubo] = decl->Dim.Index2D;
ctx->ubo_sizes[ctx->num_ubo] = decl->Range.Last + 1;
ctx->num_ubo++;
@ -616,8 +621,11 @@ iter_immediate(
int i;
int first = ctx->num_imm;
if (first > MAX_IMMEDIATE)
if (first >= ARRAY_SIZE(ctx->imm)) {
fprintf(stderr, "Number of immediates exceeded, max is: %lu\n", ARRAY_SIZE(ctx->imm));
return FALSE;
}
ctx->imm[first].type = imm->Immediate.DataType;
for (i = 0; i < 4; i++) {
if (imm->Immediate.DataType == TGSI_IMM_FLOAT32) {

Loading…
Cancel
Save