bug-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: memory overrurn and sign bug in xgps_cursor_mask


From: Nicola Pero
Subject: Re: memory overrurn and sign bug in xgps_cursor_mask
Date: Mon, 19 Nov 2001 05:33:16 +0000 (GMT)

Hi,

thanks - I applied the part of the patch fixing the memory overrun ...
which I can logically determine to be correct ... thanks for that! 

but I didn't have enough time to study/check the color code ... about
which I know nothing ... would need to study it a little ...  perhaps Adam
- who knows that part better - will have time for it tomorrow ...
(otherwise I'll study it myself later on)

thanks again for contributing - please bear with us - we try to check all
patches carefully before applying (which improves the quality of the
resulting code a lot) so in some cases it might require one day or two.

> 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  <woudshoo@xs4all.nl>
> 
>       * 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
> Bug-gnustep@gnu.org
> http://mail.gnu.org/mailman/listinfo/bug-gnustep
> 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]