[Mesa-stable] [PATCH] draw: (trivial) fix clamping of viewport index
Ian Romanick
idr at freedesktop.org
Mon Jun 23 14:37:24 PDT 2014
On 06/23/2014 01:14 PM, Brian Paul wrote:
> On 06/23/2014 02:08 PM, sroland at vmware.com wrote:
>> From: Roland Scheidegger <sroland at vmware.com>
>>
>> The old logic would let all negative values go through unclamped, with
>> potentially disastrous results (probably trying to fetch viewport values
>> from random memory locations). GL has undefined rendering for vp indices
>> outside valid range but that's a bit too undefined...
>> (The logic is now the same as in llvmpipe.)
>>
>> CC: "10.1 10.2" <mesa-stable at lists.freedesktop.org>
>> ---
>> src/gallium/auxiliary/draw/draw_private.h | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/src/gallium/auxiliary/draw/draw_private.h
>> b/src/gallium/auxiliary/draw/draw_private.h
>> index 783c3ef..d8dc2ab 100644
>> --- a/src/gallium/auxiliary/draw/draw_private.h
>> +++ b/src/gallium/auxiliary/draw/draw_private.h
>> @@ -493,7 +493,7 @@ draw_stats_clipper_primitives(struct draw_context
>> *draw,
>> static INLINE unsigned
>> draw_clamp_viewport_idx(int idx)
>> {
>> - return ((PIPE_MAX_VIEWPORTS > idx || idx < 0) ? idx : 0);
>> + return ((PIPE_MAX_VIEWPORTS > idx && idx >= 0) ? idx : 0);
>> }
>
> Personally, I find
>
> return ((idx >= 0 && idx < PIPE_MAX_VIEWPORTS) ? idx : 0);
>
> to be easier to read, but no big deal.
Yeah... part of what makes the bug in the original code hard to detect
is that idx is on different sides of the comparison operator.
> Reviewed-by: Brian Paul <brianp at vmware.com>
>
> _______________________________________________
> mesa-stable mailing list
> mesa-stable at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-stable
More information about the mesa-stable
mailing list