On 02/25/2014 07:41 AM, Juha-Pekka Heikkila wrote:
Signed-off-by: Juha-Pekka Heikkila <juhapekka.heikk...@gmail.com>
---
src/mesa/vbo/vbo_rebase.c | 28 +++++++++++++++++++++++++---
1 file changed, 25 insertions(+), 3 deletions(-)
diff --git a/src/mesa/vbo/vbo_rebase.c b/src/mesa/vbo/vbo_rebase.c
index c700621..dd754e2 100644
--- a/src/mesa/vbo/vbo_rebase.c
+++ b/src/mesa/vbo/vbo_rebase.c
@@ -60,10 +60,16 @@ static void *rebase_##TYPE( const void *ptr,
\
{ \
const TYPE *in = (TYPE *)ptr; \
TYPE *tmp_indices = malloc(count * sizeof(TYPE)); \
- GLuint i; \
+ if (tmp_indices != NULL) { \
+ GLuint i; \
\
- for (i = 0; i < count; i++) \
- tmp_indices[i] = in[i] - min_index; \
+ for (i = 0; i < count; i++) \
+ tmp_indices[i] = in[i] - min_index; \
+ } \
+ else { \
+ GET_CURRENT_CONTEXT(ctx); \
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "out of memory"); \
+ } \
\
return (void *)tmp_indices; \
}
@@ -148,6 +154,12 @@ void vbo_rebase_prims( struct gl_context *ctx,
*/
tmp_prims = malloc(sizeof(*prim) * nr_prims);
+ if (tmp_prims == NULL) {
+ GET_CURRENT_CONTEXT(ctx);
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "out of memory");
+ return;
+ }
+
for (i = 0; i < nr_prims; i++) {
tmp_prims[i] = prim[i];
tmp_prims[i].basevertex -= min_index;
@@ -185,6 +197,10 @@ void vbo_rebase_prims( struct gl_context *ctx,
if (map_ib)
ctx->Driver.UnmapBuffer(ctx, ib->obj);
+ if (tmp_indices == NULL) {
+ return;
+ }
+
tmp_ib.obj = ctx->Shared->NullBufferObj;
tmp_ib.ptr = tmp_indices;
tmp_ib.count = ib->count;
@@ -197,6 +213,12 @@ void vbo_rebase_prims( struct gl_context *ctx,
*/
tmp_prims = malloc(sizeof(*prim) * nr_prims);
+ if (tmp_prims == NULL) {
+ GET_CURRENT_CONTEXT(ctx);
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "out of memory");
+ return;
+ }
inconsistent indentation again.
+
for (i = 0; i < nr_prims; i++) {
/* If this fails, it could indicate an application error:
*/
Otherwise, the series looks OK to me.
Reviewed-by: Brian Paul <bri...@vmware.com>
_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev