diff --git a/tests/shader_runner.c b/tests/shader_runner.c index 0aca7830..2bdc6bd1 100644 --- a/tests/shader_runner.c +++ b/tests/shader_runner.c @@ -327,7 +327,9 @@ static void set_resource(struct shader_runner *runner, struct resource *resource } } - runner->resources = realloc(runner->resources, (runner->resource_count + 1) * sizeof(*runner->resources)); + if (runner->resource_count == MAX_RESOURCES) + fatal_error("Too many resources declared.\n"); + runner->resources[runner->resource_count++] = resource; } @@ -846,7 +848,6 @@ out: if (runner->resources[i]) runner->ops->destroy_resource(runner, runner->resources[i]); } - free(runner->resources); fclose(f); diff --git a/tests/shader_runner.h b/tests/shader_runner.h index 8dc77673..3bfbf48d 100644 --- a/tests/shader_runner.h +++ b/tests/shader_runner.h @@ -87,6 +87,8 @@ struct input_element unsigned int index; }; +#define MAX_RESOURCES 32 + struct shader_runner { const struct shader_runner_ops *ops; @@ -98,7 +100,7 @@ struct shader_runner uint32_t *uniforms; size_t uniform_count, uniform_capacity; - struct resource **resources; + struct resource *resources[MAX_RESOURCES]; size_t resource_count; struct sampler *samplers;