freetype: Avoid dereferencing null bitmap buffer.
For some characters (eg \r) the returned glyph will have .{.rows = 0, .width=0, .pitch = 0, .buffer = null}. In zig null[0..0] causes a panic rather than returning an empty slice.
This commit is contained in:
parent
86053d9969
commit
15c71f5135
2 changed files with 8 additions and 3 deletions
|
|
@ -21,7 +21,7 @@ pub fn main() !void {
|
|||
while (i < bitmap.rows()) : (i += 1) {
|
||||
var j: usize = 0;
|
||||
while (j < bitmap.width()) : (j += 1) {
|
||||
const char: u8 = switch (bitmap.buffer()[i * bitmap.width() + j]) {
|
||||
const char: u8 = switch (bitmap.buffer().?[i * bitmap.width() + j]) {
|
||||
0 => ' ',
|
||||
1...128 => ';',
|
||||
else => '#',
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue