diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2009-11-10 11:09:52 +0000 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2009-11-10 15:19:17 +0000 |
commit | 33cabbfca6acb5149e26f87a538a7cb79f00cad2 (patch) | |
tree | f7ebd2305ba8810d5e5484fe18beb87ffec82fda | |
parent | 67af5a99253b1295f8dc09b28863eb7dc8b59e1d (diff) |
i915: Check for overflow before overflowing.
As the immediate victim of the overflow would be to overwrite the maximum
permissible value, the test was optimistic.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
-rw-r--r-- | src/i915_3d.h | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/i915_3d.h b/src/i915_3d.h index 500817f4..f85780aa 100644 --- a/src/i915_3d.h +++ b/src/i915_3d.h @@ -420,8 +420,8 @@ do { \ */ #define FS_LOCALS(x) \ uint32_t _shader_buf[(x) * 3]; \ - int _max_shader_commands = x; \ - int _cur_shader_commands + unsigned int _max_shader_commands = x; \ + unsigned int _cur_shader_commands #define FS_BEGIN() \ do { \ @@ -430,12 +430,13 @@ do { \ #define FS_OUT(_shaderop) \ do { \ + if (_cur_shader_commands >= _max_shader_commands) \ + FatalError("fragment shader command buffer exceeded (%d)\n", \ + _cur_shader_commands); \ _shader_buf[_cur_shader_commands * 3 + 0] = _shaderop.ui[0]; \ _shader_buf[_cur_shader_commands * 3 + 1] = _shaderop.ui[1]; \ _shader_buf[_cur_shader_commands * 3 + 2] = _shaderop.ui[2]; \ - if (++_cur_shader_commands > _max_shader_commands) \ - FatalError("fragment shader command buffer exceeded (%d)\n", \ - _cur_shader_commands); \ + ++_cur_shader_commands; \ } while (0) #define FS_END() \ |