Same memory overrurn as in xgps_cursor_mask. 
Also treating the argument as a signed char array 
messed up the foreground / background logic.




[--- ChangeLog and Diff -----------------------------------------------]


2001-11-19  Willem Rein Oudshoorn  <[EMAIL PROTECTED]>

        * xgps-devel/Source/SharedX/XGContextWindow.m (xgps_cursor_image): 
        fixed memory overrun and fore/background logic.


*** ../xgps/Source/SharedX/XGContextWindow.m    Wed Oct 17 05:59:52 2001
--- Source/SharedX/XGContextWindow.m    Mon Nov 19 22:20:40 2001
***************
*** 2031,2037 ****
  }
  
  Pixmap
! xgps_cursor_image(Display *xdpy, Drawable draw, const char *data, 
                  int w, int h, int colors, XColor *fg, XColor *bg)
  {
    int j, i, min, max;
--- 2030,2036 ----
  }
  
  Pixmap
! xgps_cursor_image(Display *xdpy, Drawable draw, const unsigned char *data, 
                  int w, int h, int colors, XColor *fg, XColor *bg)
  {
    int j, i, min, max;
***************
*** 2040,2046 ****
    char *aData = calloc(1, bitmapSize);
    char *cData = aData;
  
!   min = 256;
    max = 0;
    if (colors == 4 || colors == 3)
      {
--- 2039,2045 ----
    char *aData = calloc(1, bitmapSize);
    char *cData = aData;
  
!   min = 1 << 16;
    max = 0;
    if (colors == 4 || colors == 3)
      {
***************
*** 2048,2057 ****
        for (j = 0; j < h; j++)
        {
          k = 0;
!         for (i = 0; i < w; i++)
            {
!             int color = ((0.3*data[0]) + (0.59*data[1]) + (0.11*data[2]));
!             if (color > 128)
                *cData |= (0x01 << k);
              if (color < min)
                {
--- 2047,2066 ----
        for (j = 0; j < h; j++)
        {
          k = 0;
!         for (i = 0; i < w; i++, k++)
            {
!               // color is in the range 0..65535
!               // and the value is the percieved brightness, obtained by
!               // avareging 0.3 red + 0.59 green + 0.11 blue.
!             int color = ((77 * data[0]) + (151 * data[1]) + (28 * data[2]));
! 
!             if (k > 7)
!               {
!                 cData++;
!                 k = 0;
!               }
! 
!             if (color > (1 << 15))
                *cData |= (0x01 << k);
              if (color < min)
                {
***************
*** 2070,2081 ****
              data += 3;
              if (colors == 4)
                data++;
-             k++;
-             if (k > 7)
-               {
-                 cData++;
-                 k = 0;
-               }
            }
          cData++;
        }
--- 2079,2084 ----


_______________________________________________
Bug-gnustep mailing list
[EMAIL PROTECTED]
http://mail.gnu.org/mailman/listinfo/bug-gnustep

Reply via email to