Skip to content

Commit

Permalink
convert to i32 first to avoid underflow
Browse files Browse the repository at this point in the history
despite h and usedfont->h being unsigned, C allows the result to be negative

I only caught this by running the debug build in xephyr, in release I guess
something reasonable was happening automatically (probably the same as C)
  • Loading branch information
ntBre committed Nov 23, 2024
1 parent 744c214 commit 5770468
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/drw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -569,7 +569,7 @@ pub(crate) fn text(
if utf8strlen != 0 {
if render != 0 {
ty = y
+ (h - (*usedfont).h) as i32 / 2
+ (h as i32 - (*usedfont).h as i32) / 2
+ (*(*usedfont).xfont).ascent;
log::trace!("text: XftDrawStringUtf8");
xft::XftDrawStringUtf8(
Expand Down

0 comments on commit 5770468

Please sign in to comment.