Commit a50b0278 authored by Juha-Pekka Heikkila's avatar Juha-Pekka Heikkila Committed by Ian Romanick

mesa: add extra null checks in vbo_rebase_prims()

v2 [idr]: Move declarations before code to prevent MSVC build breaks.
Signed-off-by: 's avatarJuha-Pekka Heikkila <juhapekka.heikkila@gmail.com>
Reviewed-by: 's avatarMatt Turner <mattst88@gmail.com>
Signed-off-by: 's avatarIan Romanick <ian.d.romanick@intel.com>
parent dc675919
......@@ -58,9 +58,14 @@ static void *rebase_##TYPE( const void *ptr, \
GLuint count, \
TYPE min_index ) \
{ \
const TYPE *in = (TYPE *)ptr; \
TYPE *tmp_indices = malloc(count * sizeof(TYPE)); \
GLuint i; \
const TYPE *in = (TYPE *)ptr; \
TYPE *tmp_indices = malloc(count * sizeof(TYPE)); \
\
if (tmp_indices == NULL) { \
_mesa_error_no_memory(__func__); \
return NULL; \
} \
\
for (i = 0; i < count; i++) \
tmp_indices[i] = in[i] - min_index; \
......@@ -148,6 +153,11 @@ void vbo_rebase_prims( struct gl_context *ctx,
*/
tmp_prims = malloc(sizeof(*prim) * nr_prims);
if (tmp_prims == NULL) {
_mesa_error_no_memory(__func__);
return;
}
for (i = 0; i < nr_prims; i++) {
tmp_prims[i] = prim[i];
tmp_prims[i].basevertex -= min_index;
......@@ -186,6 +196,10 @@ void vbo_rebase_prims( struct gl_context *ctx,
if (map_ib)
ctx->Driver.UnmapBuffer(ctx, ib->obj, MAP_INTERNAL);
if (tmp_indices == NULL) {
return;
}
tmp_ib.obj = ctx->Shared->NullBufferObj;
tmp_ib.ptr = tmp_indices;
tmp_ib.count = ib->count;
......@@ -198,6 +212,11 @@ void vbo_rebase_prims( struct gl_context *ctx,
*/
tmp_prims = malloc(sizeof(*prim) * nr_prims);
if (tmp_prims == NULL) {
_mesa_error_no_memory(__func__);
return;
}
for (i = 0; i < nr_prims; i++) {
/* If this fails, it could indicate an application error:
*/
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment