Silence more code scanning warnings

This commit is contained in:
Kovid Goyal 2020-07-07 10:01:38 +05:30
parent 521f921424
commit ee3462592a
No known key found for this signature in database
GPG key ID: 06BC317B515ACE7C
3 changed files with 4 additions and 4 deletions

View file

@ -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++) {

View file

@ -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;

View file

@ -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;
}