diff options
author | Juha-Pekka Heikkila <[email protected]> | 2014-04-27 23:04:58 +0300 |
---|---|---|
committer | Ian Romanick <[email protected]> | 2014-05-02 12:00:30 -0700 |
commit | a50b02783bf926477e1edab5c039912802c67f61 (patch) | |
tree | 0af64c1711297ac7a78c8bfb48ebb7b2134190ab /src/mesa/vbo/vbo_rebase.c | |
parent | dc675919d30df407269a5e5b3d682e7801db3f1e (diff) |
mesa: add extra null checks in vbo_rebase_prims()
v2 [idr]: Move declarations before code to prevent MSVC build breaks.
Signed-off-by: Juha-Pekka Heikkila <[email protected]>
Reviewed-by: Matt Turner <[email protected]>
Signed-off-by: Ian Romanick <[email protected]>
Diffstat (limited to 'src/mesa/vbo/vbo_rebase.c')
-rw-r--r-- | src/mesa/vbo/vbo_rebase.c | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/src/mesa/vbo/vbo_rebase.c b/src/mesa/vbo/vbo_rebase.c index f3fe5f75708..82a0b8e2b9d 100644 --- a/src/mesa/vbo/vbo_rebase.c +++ b/src/mesa/vbo/vbo_rebase.c @@ -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: */ |