[Bug 37131] New: Clang Static Analyzer: Division by zero

wine-bugs at winehq.org wine-bugs at winehq.org
Sat Aug 16 13:39:36 CDT 2014


https://bugs.winehq.org/show_bug.cgi?id=37131

            Bug ID: 37131
           Summary: Clang Static Analyzer:  Division by zero
           Product: Wine
           Version: 1.7.22
          Hardware: x86-64
                OS: Linux
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: -unknown
          Assignee: wine-bugs at winehq.org
          Reporter: lukebenes at hotmail.com

Clang Static Analyzer identifies Division by zero

File: dlls/winex11.drv/palette.c

Location: line 601, column 43

Description: Division by zero

#define NB_RESERVED_COLORS 20
...
static void X11DRV_PALETTE_FillDefaultColors(....)
{
  ...
  int i = 0, idx = 0;
  int red, no_r, inc_r;
  ...
  if (palette_size <= NB_RESERVED_COLORS)
    return;
  while (i*i*i < (palette_size - NB_RESERVED_COLORS)) i++;
  no_r = no_g = no_b = --i;
  ...
  inc_r = (255 - NB_COLORCUBE_START_INDEX)/no_r;
  //Clang: Division by zero
  ...
}

The code will continue executing if the palette_size variable is larger than or
equal to 21. With the value 21, the 'i' variable will be first incremented by
one and then decremented by one. As a result, the 'i' variable will remain
equal to zero, which will cause the division-by-zero error.

-- 
Do not reply to this email, post in Bugzilla using the
above URL to reply.
You are receiving this mail because:
You are watching all bug changes.



More information about the wine-bugs mailing list