Hi,
In the definitions of the above-mentioned lispbuilder-sdl functions, the
macro sdl-base::check-bounds is used incorrectly, with (width surface)
and (height surface) as the upper bounds, instead of (- (width surface)
1) and (- (height surface) 1), respectively. This, of course, leads to
possible memory corruption if one draws a pixel to the edge of the
surface. The attached patch gives the required changes. Note that
sdl:draw-line-* uses check-bounds correctly.
I haven't had any problems with sdl-gfx:draw-pixel-*. (Now I see that
the SDL_gfx library does the range checking itself.) If one uses
lispbuilder-sdl-gfx, should one use the sdl-gfx version of a symbol
whenever it is exported by both the sdl and sdl-gfx packages?
Kind regards,
Michael
Index: trunk/lispbuilder-sdl/sdl/drawing-primitives.lisp
===================================================================
--- trunk/lispbuilder-sdl/sdl/drawing-primitives.lisp (revision 667)
+++ trunk/lispbuilder-sdl/sdl/drawing-primitives.lisp (working copy)
@@ -656,8 +656,8 @@
(check-type surface sdl-surface)
(check-type color sdl-color)
(when clipping-p
- (sdl-base::check-bounds 0 (width surface) x)
- (sdl-base::check-bounds 0 (height surface) y))
+ (sdl-base::check-bounds 0 (- (width surface) 1) x)
+ (sdl-base::check-bounds 0 (- (height surface) 1) y))
(sdl-base::with-pixel (pix (fp surface))
(sdl-base::write-pixel pix x y (map-color color surface)))
surface)
@@ -668,8 +668,8 @@
(defun read-pixel-* (x y &key (clipping-p t) (surface *default-surface*))
(when clipping-p
- (sdl-base::check-bounds 0 (width surface) x)
- (sdl-base::check-bounds 0 (height surface) y))
+ (sdl-base::check-bounds 0 (- (width surface) 1) x)
+ (sdl-base::check-bounds 0 (- (height surface) 1) y))
(sdl-base::with-pixel (surf (fp surface))
(multiple-value-bind (rgba r g b a)
(sdl-base::read-pixel surf x y)
_______________________________________________
application-builder mailing list
application-builder@lispniks.com
http://www.lispniks.com/mailman/listinfo/application-builder