Skip to content

Commit

Permalink
BB:dimRect/lightenRect: add missing bounds check when use_cblitbuffer (
Browse files Browse the repository at this point in the history
…#648)

Fix segfaults with highlights spanning multiple pages
  • Loading branch information
poire-z authored Apr 15, 2018
1 parent ebdb42f commit 7a294b4
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions ffi/blitbuffer.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1176,6 +1176,8 @@ dim color values in rectangular area
function BB_mt.__index:dimRect(x, y, w, h, by)
local color = Color8A(255, 255*(by or 0.5))
if use_cblitbuffer then
w, x = BB.checkBounds(w, x, 0, self:getWidth(), 0xFFFF)
h, y = BB.checkBounds(h, y, 0, self:getHeight(), 0xFFFF)
cblitbuffer.BB_blend_rect(ffi.cast("struct BlitBuffer *", self),
x, y, w, h, color:getColorRGB32())
else
Expand All @@ -1195,6 +1197,8 @@ lighten color values in rectangular area
function BB_mt.__index:lightenRect(x, y, w, h, by)
local color = Color8A(0, 255*(by or 0.5))
if use_cblitbuffer then
w, x = BB.checkBounds(w, x, 0, self:getWidth(), 0xFFFF)
h, y = BB.checkBounds(h, y, 0, self:getHeight(), 0xFFFF)
cblitbuffer.BB_blend_rect(ffi.cast("struct BlitBuffer *", self),
x, y, w, h, color:getColorRGB32())
else
Expand Down

0 comments on commit 7a294b4

Please sign in to comment.