diff --git a/kitty/fonts.c b/kitty/fonts.c index b6c4c7b9a..04950df43 100644 --- a/kitty/fonts.c +++ b/kitty/fonts.c @@ -176,7 +176,7 @@ font_group_for(double font_sz_in_pts, double logical_dpi_x, double logical_dpi_y static inline void clear_canvas(FontGroup *fg) { - if (fg->canvas) memset(fg->canvas, 0, CELLS_IN_CANVAS * fg->cell_width * fg->cell_height * sizeof(pixel)); + if (fg->canvas) memset(fg->canvas, 0, sizeof(pixel) * CELLS_IN_CANVAS * fg->cell_width * fg->cell_height); } @@ -1388,7 +1388,7 @@ concat_cells(PyObject UNUSED *self, PyObject *args) { PyObject *cells; if (!PyArg_ParseTuple(args, "IIpO!", &cell_width, &cell_height, &is_32_bit, &PyTuple_Type, &cells)) return NULL; size_t num_cells = PyTuple_GET_SIZE(cells), r, c, i; - PyObject *ans = PyBytes_FromStringAndSize(NULL, 4 * cell_width * cell_height * num_cells); + PyObject *ans = PyBytes_FromStringAndSize(NULL, (size_t)4 * cell_width * cell_height * num_cells); if (ans == NULL) return PyErr_NoMemory(); pixel *dest = (pixel*)PyBytes_AS_STRING(ans); for (r = 0; r < cell_height; r++) { diff --git a/kitty/freetype.c b/kitty/freetype.c index 80403a4ad..43fbb1f5c 100644 --- a/kitty/freetype.c +++ b/kitty/freetype.c @@ -457,7 +457,7 @@ downsample_bitmap(ProcessedBitmap *bm, unsigned int width, unsigned int cell_hei // it matters float ratio = MAX((float)bm->width / width, (float)bm->rows / cell_height); int factor = (int)ceilf(ratio); - uint8_t *dest = calloc(4, width * cell_height); + uint8_t *dest = calloc(4, (size_t)width * cell_height); if (dest == NULL) fatal("Out of memory"); uint8_t *d = dest; diff --git a/kitty/glfw.c b/kitty/glfw.c index 961fa4870..72208ae71 100644 --- a/kitty/glfw.c +++ b/kitty/glfw.c @@ -1079,7 +1079,7 @@ set_custom_cursor(PyObject *self UNUSED, PyObject *args) { size_t count = MIN((size_t)PyTuple_GET_SIZE(images), arraysz(gimages)); for (size_t i = 0; i < count; i++) { if (!PyArg_ParseTuple(PyTuple_GET_ITEM(images, i), "s#ii", &gimages[i].pixels, &sz, &gimages[i].width, &gimages[i].height)) return NULL; - if (gimages[i].width * gimages[i].height * 4 != sz) { + if ((Py_ssize_t)gimages[i].width * gimages[i].height * 4 != sz) { PyErr_SetString(PyExc_ValueError, "The image data size does not match its width and height"); return NULL; }