diff options
author | José Fonseca <[email protected]> | 2012-11-05 11:18:07 +0000 |
---|---|---|
committer | José Fonseca <[email protected]> | 2012-11-05 11:18:07 +0000 |
commit | 3700bd115841958cc9c211475d3069298e4ff266 (patch) | |
tree | cb8769809e384c5094b2f363dbd7d4cabcf692cb /src/gallium/drivers/trace | |
parent | 99c45c5aa4b60e1fd55ff4fde6ff6d1a391987d9 (diff) |
trace: Prevent segfault when passing NULL to set_vertex_buffers.
State tracker now passes NULL buffer array to unbind buffers.
Diffstat (limited to 'src/gallium/drivers/trace')
-rw-r--r-- | src/gallium/drivers/trace/tr_context.c | 2 | ||||
-rw-r--r-- | src/gallium/drivers/trace/tr_dump.h | 36 |
2 files changed, 23 insertions, 15 deletions
diff --git a/src/gallium/drivers/trace/tr_context.c b/src/gallium/drivers/trace/tr_context.c index ba1882ea652..fed95c62a5c 100644 --- a/src/gallium/drivers/trace/tr_context.c +++ b/src/gallium/drivers/trace/tr_context.c @@ -1077,7 +1077,7 @@ trace_context_set_vertex_buffers(struct pipe_context *_pipe, trace_dump_struct_array(vertex_buffer, buffers, num_buffers); trace_dump_arg_end(); - if (num_buffers) { + if (buffers) { struct pipe_vertex_buffer *_buffers = MALLOC(num_buffers * sizeof(*_buffers)); memcpy(_buffers, buffers, num_buffers * sizeof(*_buffers)); for (i = 0; i < num_buffers; i++) diff --git a/src/gallium/drivers/trace/tr_dump.h b/src/gallium/drivers/trace/tr_dump.h index 5739e8694a0..ef0129281c1 100644 --- a/src/gallium/drivers/trace/tr_dump.h +++ b/src/gallium/drivers/trace/tr_dump.h @@ -137,26 +137,34 @@ void trace_dump_transfer_ptr(struct pipe_transfer *_transfer); #define trace_dump_array(_type, _obj, _size) \ do { \ - size_t idx; \ - trace_dump_array_begin(); \ - for(idx = 0; idx < (_size); ++idx) { \ - trace_dump_elem_begin(); \ - trace_dump_##_type((_obj)[idx]); \ - trace_dump_elem_end(); \ + if (_obj) { \ + size_t idx; \ + trace_dump_array_begin(); \ + for(idx = 0; idx < (_size); ++idx) { \ + trace_dump_elem_begin(); \ + trace_dump_##_type((_obj)[idx]); \ + trace_dump_elem_end(); \ + } \ + trace_dump_array_end(); \ + } else { \ + trace_dump_null(); \ } \ - trace_dump_array_end(); \ } while(0) #define trace_dump_struct_array(_type, _obj, _size) \ do { \ - size_t idx; \ - trace_dump_array_begin(); \ - for(idx = 0; idx < (_size); ++idx) { \ - trace_dump_elem_begin(); \ - trace_dump_##_type(&(_obj)[idx]); \ - trace_dump_elem_end(); \ + if (_obj) { \ + size_t idx; \ + trace_dump_array_begin(); \ + for(idx = 0; idx < (_size); ++idx) { \ + trace_dump_elem_begin(); \ + trace_dump_##_type(&(_obj)[idx]); \ + trace_dump_elem_end(); \ + } \ + trace_dump_array_end(); \ + } else { \ + trace_dump_null(); \ } \ - trace_dump_array_end(); \ } while(0) #define trace_dump_member(_type, _obj, _member) \ |