plotters-rs / plotters

A rust drawing library for high quality data plotting for both WASM and native, statically and realtimely 🦀 📈🚀
https://plotters-rs.github.io/home/
MIT License
3.89k stars 281 forks source link

Fix overflow in `blit_bitmap` #545

Closed x3ro closed 9 months ago

x3ro commented 9 months ago

Hey folks, thanks for building this project 🦀

I ran into an index out of bounds error when playing around with the blit_bitmap example when using the SvgBackend instead of the BitmapBackend:

  1. blit_bitmap receives dimensions iw, ih as parameters, but also calls get_size() to retrieve the size of the DrawingBackend
  2. It then proceeds to use w, h to check whether or not the image is being drawn out of bounds (I think)
  3. However, it appears that there was a mixup when implementing the image data access, where w was used instead of iw

The attached change fixes this, though I'm not entirely sure whether the fix takes everything into account 🤔