File tree Expand file tree Collapse file tree 2 files changed +10
-0
lines changed Expand file tree Collapse file tree 2 files changed +10
-0
lines changed Original file line number Diff line number Diff line change @@ -8,6 +8,10 @@ projects using an SPI interface.
8
8
9
9
## [ Unreleased] - ReleaseDate
10
10
11
+ ### Fixed
12
+
13
+ - [ #4 ] ( https://github.com/jamwaffles/ssd1331/pull/4 ) Guard against negative pixel coordinates panicking ` draw_pixel() ` calls.
14
+
11
15
## [ 0.2.0-alpha.2]
12
16
13
17
### Changed
Original file line number Diff line number Diff line change @@ -372,6 +372,12 @@ where
372
372
fn draw_pixel ( & mut self , pixel : drawable:: Pixel < Rgb565 > ) {
373
373
let drawable:: Pixel ( pos, color) = pixel;
374
374
375
+ // Guard against negative values. All positive i32 values from `pos` can be represented in
376
+ // the `u32`s that `set_pixel()` accepts.
377
+ if pos. x < 0 || pos. y < 0 {
378
+ return ;
379
+ }
380
+
375
381
self . set_pixel (
376
382
( pos. x ) . try_into ( ) . unwrap ( ) ,
377
383
( pos. y ) . try_into ( ) . unwrap ( ) ,
You can’t perform that action at this time.
0 commit comments