On Wed, Mar 12, 2014 at 2:11 PM, Juha-Pekka Heikkila <juhapekka.heikk...@gmail.com> wrote: > Signed-off-by: Juha-Pekka Heikkila <juhapekka.heikk...@gmail.com> > --- > src/mesa/vbo/vbo_rebase.c | 25 ++++++++++++++++++++++--- > 1 file changed, 22 insertions(+), 3 deletions(-) > > diff --git a/src/mesa/vbo/vbo_rebase.c b/src/mesa/vbo/vbo_rebase.c > index f3fe5f7..7aa8d08 100644 > --- a/src/mesa/vbo/vbo_rebase.c > +++ b/src/mesa/vbo/vbo_rebase.c > @@ -60,10 +60,15 @@ 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 { \ > + _mesa_error_no_memory(__FUNCTION__); \ > + } \
I'd probably check malloc's return value and return NULL if it failed and avoid indenting the for loop. _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev