From 2c54714646e8cc34e38fb61a78e1c8c52c8d251d Mon Sep 17 00:00:00 2001 From: Jinhao Date: Thu, 12 Sep 2019 05:34:49 +0800 Subject: [PATCH 1/2] fix crash that could occur when calling pixel_buffer::put with rgb24 --- source/paint/pixel_buffer.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/source/paint/pixel_buffer.cpp b/source/paint/pixel_buffer.cpp index 81316842..304bbc33 100644 --- a/source/paint/pixel_buffer.cpp +++ b/source/paint/pixel_buffer.cpp @@ -238,10 +238,18 @@ namespace nana{ namespace paint auto d = rawptr; const unsigned char* s; + int src_line_bytes; + if (is_negative) + { s = rawbits; + src_line_bytes = -static_cast(bytes_per_line); + } else + { s = rawbits + bytes_per_line * (height - 1); + src_line_bytes = static_cast(bytes_per_line); + } for(std::size_t i = 0; i < height; ++i) { @@ -256,7 +264,7 @@ namespace nana{ namespace paint s_p += 3; } d += pixel_size.width; - s -= bytes_per_line; + s -= src_line_bytes; } } else if(16 == bits_per_pixel) From 2234d06beae70de0191c2050d85c498afc38e2a6 Mon Sep 17 00:00:00 2001 From: Jinhao Date: Mon, 23 Sep 2019 01:47:36 +0800 Subject: [PATCH 2/2] fix issue graphics::gradual_rectangle off by one(#475) --- source/paint/graphics.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/paint/graphics.cpp b/source/paint/graphics.cpp index c622aa3f..20048291 100644 --- a/source/paint/graphics.cpp +++ b/source/paint/graphics.cpp @@ -1473,7 +1473,7 @@ namespace paint { if (vertical) { - int x1 = good_rct.x, x2 = good_rct.right(); + int x1 = good_rct.x, x2 = good_rct.right() - 1; auto y = good_rct.y; for (; y < endpos; ++y) { @@ -1489,7 +1489,7 @@ namespace paint } else { - int y1 = good_rct.y, y2 = good_rct.bottom(); + int y1 = good_rct.y, y2 = good_rct.bottom() - 1; auto x = good_rct.x; for (; x < endpos; ++x) {