radeonsi: reject invalid vertex element formats
authorMarek Olšák <marek.olsak@amd.com>
Wed, 18 Jan 2017 21:35:19 +0000 (22:35 +0100)
committerMarek Olšák <marek.olsak@amd.com>
Thu, 19 Jan 2017 15:38:37 +0000 (16:38 +0100)
This should fix a coverity defect.

Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
Reviewed-by: Edward O'Callaghan <funfunctor@folklore1984.net>
src/gallium/drivers/radeonsi/si_state.c

index 876cbf6a34b9ff78bcfe227e3a71644f57bcd9e1..4a9ca812174fd492406404689328fc98289a0a7e 100644 (file)
@@ -3366,6 +3366,11 @@ static void *si_create_vertex_elements(struct pipe_context *ctx,
 
                desc = util_format_description(elements[i].src_format);
                first_non_void = util_format_get_first_non_void_channel(elements[i].src_format);
+               if (first_non_void < 0) {
+                       FREE(v);
+                       return NULL;
+               }
+
                data_format = si_translate_buffer_dataformat(ctx->screen, desc, first_non_void);
                num_format = si_translate_buffer_numformat(ctx->screen, desc, first_non_void);
                channel = &desc->channel[first_non_void];