util: fix valgrind errors when dumping pipe_draw_info
authorNicolai Hähnle <nicolai.haehnle@amd.com>
Fri, 18 Aug 2017 17:29:49 +0000 (19:29 +0200)
committerNicolai Hähnle <nicolai.haehnle@amd.com>
Wed, 23 Aug 2017 11:53:54 +0000 (13:53 +0200)
Various index-related fields are only initialized when required, so
they should only be dumped in those cases.

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
src/gallium/auxiliary/util/u_dump_state.c

index 70bbf5c9fad6b235e19707f5d193c68e0b03df21..c263021a9f6d0ab6b9d505cb243a9ac8dd7a412e 100644 (file)
@@ -919,9 +919,15 @@ util_dump_draw_info(FILE *stream, const struct pipe_draw_info *state)
    util_dump_member(stream, uint, state, max_index);
 
    util_dump_member(stream, bool, state, primitive_restart);
-   util_dump_member(stream, uint, state, restart_index);
-
-   util_dump_member(stream, ptr, state, index.resource);
+   if (state->primitive_restart)
+      util_dump_member(stream, uint, state, restart_index);
+
+   if (state->index_size) {
+      if (state->has_user_indices)
+         util_dump_member(stream, ptr, state, index.user);
+      else
+         util_dump_member(stream, ptr, state, index.resource);
+   }
    util_dump_member(stream, ptr, state, count_from_stream_output);
 
    if (!state->indirect) {