diff --git a/kitty/fonts.c b/kitty/fonts.c index 04950df43..9af6df8e1 100644 --- a/kitty/fonts.c +++ b/kitty/fonts.c @@ -457,7 +457,7 @@ calc_cell_metrics(FontGroup *fg) { fg->cell_width = cell_width; fg->cell_height = cell_height; fg->baseline = baseline; fg->underline_position = underline_position; fg->underline_thickness = underline_thickness, fg->strikethrough_position = strikethrough_position, fg->strikethrough_thickness = strikethrough_thickness; free(fg->canvas); - fg->canvas = calloc(CELLS_IN_CANVAS * fg->cell_width * fg->cell_height, sizeof(pixel)); + fg->canvas = calloc((size_t)CELLS_IN_CANVAS * fg->cell_width * fg->cell_height, sizeof(pixel)); if (!fg->canvas) fatal("Out of memory allocating canvas for font group"); } diff --git a/kitty/freetype.c b/kitty/freetype.c index 43fbb1f5c..3917cb894 100644 --- a/kitty/freetype.c +++ b/kitty/freetype.c @@ -497,7 +497,8 @@ static inline bool render_color_bitmap(Face *self, int glyph_id, ProcessedBitmap *ans, unsigned int cell_width, unsigned int cell_height, unsigned int num_cells, unsigned int baseline) { (void)baseline; unsigned short best = 0, diff = USHRT_MAX; - for (short i = 0; i < (short)self->face->num_fixed_sizes; i++) { + const short limit = self->face->num_fixed_sizes; + for (short i = 0; i < limit; i++) { unsigned short w = self->face->available_sizes[i].width; unsigned short d = w > (unsigned short)cell_width ? w - (unsigned short)cell_width : (unsigned short)cell_width - w; if (d < diff) { diff --git a/kitty/graphics.c b/kitty/graphics.c index a94c11186..31077a02d 100644 --- a/kitty/graphics.c +++ b/kitty/graphics.c @@ -348,7 +348,7 @@ handle_add_command(GraphicsManager *self, const GraphicsCommand *g, const uint8_ break; case RGB: case RGBA: - img->load_data.data_sz = g->data_width * g->data_height * (fmt / 8); + img->load_data.data_sz = (size_t)g->data_width * g->data_height * (fmt / 8); if (!img->load_data.data_sz) ABRT(EINVAL, "Zero width/height not allowed"); img->load_data.is_4byte_aligned = fmt == RGBA || (img->width % 4 == 0); img->load_data.is_opaque = fmt == RGB;