Forgot to initialize canvas when rendering sample text onto it

This commit is contained in:
Kovid Goyal
2024-05-12 14:20:21 +05:30
parent 5a189b1afe
commit 22ecba93e5
2 changed files with 2 additions and 0 deletions

View File

@@ -933,6 +933,7 @@ render_sample_text(Face *self, PyObject *args) {
unsigned int cell_width, cell_height, baseline, underline_position, underline_thickness, strikethrough_position, strikethrough_thickness;
cell_metrics((PyObject*)self, &cell_width, &cell_height, &baseline, &underline_position, &underline_thickness, &strikethrough_position, &strikethrough_thickness);
pixel *canvas = (pixel*)PyBytes_AS_STRING(pbuf);
memset(canvas, 0, PyBytes_GET_SIZE(pbuf));
if (cell_width > canvas_width) goto end;
for (ssize_t n = 0; n < PyUnicode_GET_LENGTH(ptext); n++) {