Bug 37648

Summary: Logic error in mesa/main/teximage.c:texsubimage
Product: Mesa Reporter: Ryan Sleevi <rsleevi>
Component: Mesa coreAssignee: mesa-dev
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: medium    
Version: git   
Hardware: Other   
OS: All   
Whiteboard:
i915 platform: i915 features:

Description Ryan Sleevi 2011-05-26 17:52:24 UTC
This was reported by a static analyzer tool run against the Chromium projects, which make use of Mesa. The downstream bug is http://code.google.com/p/chromium/issues/detail?id=84134

The original bug was reported against the Mesa used by Chromium, which is Mesa 7.6, and is as follows:

V501 There are identical sub-expressions to the left and to the right of the '&&' operator: width > 0 && height > 0 && height > 0 mesa teximage.c 2801

void GLAPIENTRY
_mesa_TexSubImage3D(...)
{
  ...
  else if (width > 0 && height > 0 && height > 0) {
  ...
}


However, this bug also exists in HEAD at http://cgit.freedesktop.org/mesa/mesa/tree/src/mesa/main/teximage.c#n2696
in the refactored method:

static void
texsubimage(...)
{
  ...
      else if (width > 0 && height > 0 && height > 0) {
         /* If we have a border, offset=-1 is legal.  Bias by border width. */
  ...
}

The issue is the additional height > 0 check. I'm uncertain if this is a redundant check, and can be eliminated, or if it should be checking depth > 0
Comment 1 Brian Paul 2011-05-26 18:24:23 UTC
It should be "depth > 0".  I'll fix it in git.  Thanks.
Comment 2 Brian Paul 2011-05-26 18:27:28 UTC
Fixed w/ commit 4609e80288bacf19af99b0ed7656eef9bb280912

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.