Skip to content

Commit

Permalink
Fix buffer allocation for doubled font
Browse files Browse the repository at this point in the history
The problem occurs if the font height becomes greater than 32 when
doubling. Another problem is that if the height is greater than 32 then
the vpitch value becomes incorrect and cannot be loaded into the kernel.

As a solution, we need to adjust vpitch before buffer allocation.

Link: #109
Co-developed-by: Oleg Bulatov <oleg@bulatov.me>
Signed-off-by: Alexey Gladkov <legion@kernel.org>
  • Loading branch information
legionus committed Feb 5, 2024
1 parent b1511a2 commit 331fbbe
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/libkfont/setfont.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ try_loadfont(struct kfont_context *ctx, int fd, const unsigned char *inbuf,
unsigned int kbytewidth = (2 * width + 7) / 8;
unsigned int charsize = height * bytewidth;

if (2*height > vpitch)
vpitch = 2*height;

kcharsize = vpitch * kbytewidth;
buflen = kcharsize * ((fontsize < 128) ? 128 : fontsize);

Expand Down

0 comments on commit 331fbbe

Please sign in to comment.