diff --git a/kitty/child-monitor.c b/kitty/child-monitor.c index fbc138dae..4ce234338 100644 --- a/kitty/child-monitor.c +++ b/kitty/child-monitor.c @@ -503,7 +503,7 @@ collect_cursor_info(CursorRenderInfo *ans, Window *w, monotonic_t now, OSWindow int d = monotonic_t_to_ms(OPT(cursor_blink_interval)); int n = t / d; do_draw_cursor = n % 2 == 0 ? true : false; - monotonic_t bucket = ms_to_monotonic_t((n + 1) * d); + monotonic_t bucket = ms_to_monotonic_t((monotonic_t)(n + 1) * d); monotonic_t delay = bucket - time_since_start_blink; set_maximum_wait(delay); } diff --git a/kitty/graphics.c b/kitty/graphics.c index a41a675a8..a94c11186 100644 --- a/kitty/graphics.c +++ b/kitty/graphics.c @@ -461,7 +461,7 @@ handle_add_command(GraphicsManager *self, const GraphicsCommand *g, const uint8_ } else img->load_data.data = img->load_data.mapped_file; } } - size_t required_sz = (img->load_data.is_opaque ? 3 : 4) * img->width * img->height; + size_t required_sz = (size_t)(img->load_data.is_opaque ? 3 : 4) * img->width * img->height; if (img->load_data.data_sz != required_sz) ABRT(EINVAL, "Image dimensions: %ux%u do not match data size: %zu, expected size: %zu", img->width, img->height, img->load_data.data_sz, required_sz); if (LIKELY(img->data_loaded && send_to_gpu)) { send_image_to_gpu(&img->texture_id, img->load_data.data, img->width, img->height, img->load_data.is_opaque, img->load_data.is_4byte_aligned, false, REPEAT_CLAMP); diff --git a/kitty/line-buf.c b/kitty/line-buf.c index 55a36aab4..58d6839ce 100644 --- a/kitty/line-buf.c +++ b/kitty/line-buf.c @@ -536,8 +536,8 @@ linebuf_rewrap(LineBuf *self, LineBuf *other, index_type *num_content_lines_befo if (other->xnum == self->xnum && other->ynum == self->ynum) { memcpy(other->line_map, self->line_map, sizeof(index_type) * self->ynum); memcpy(other->line_attrs, self->line_attrs, sizeof(bool) * self->ynum); - memcpy(other->cpu_cell_buf, self->cpu_cell_buf, self->xnum * self->ynum * sizeof(CPUCell)); - memcpy(other->gpu_cell_buf, self->gpu_cell_buf, self->xnum * self->ynum * sizeof(GPUCell)); + memcpy(other->cpu_cell_buf, self->cpu_cell_buf, (size_t)self->xnum * self->ynum * sizeof(CPUCell)); + memcpy(other->gpu_cell_buf, self->gpu_cell_buf, (size_t)self->xnum * self->ynum * sizeof(GPUCell)); *num_content_lines_before = self->ynum; *num_content_lines_after = self->ynum; return; } diff --git a/kitty/png-reader.c b/kitty/png-reader.c index e534dd8d7..66352865f 100644 --- a/kitty/png-reader.c +++ b/kitty/png-reader.c @@ -77,7 +77,7 @@ inflate_png_inner(png_read_data *d, const uint8_t *buf, size_t bufsz) { png_read_update_info(png, info); int rowbytes = png_get_rowbytes(png, info); - d->sz = rowbytes * d->height * sizeof(png_byte); + d->sz = sizeof(png_byte) * rowbytes * d->height; d->decompressed = malloc(d->sz + 16); if (d->decompressed == NULL) ABRT(ENOMEM, "Out of memory allocating decompression buffer for PNG"); d->row_pointers = malloc(d->height * sizeof(png_bytep)); diff --git a/kitty/screen.c b/kitty/screen.c index ef28a5996..f016cbf20 100644 --- a/kitty/screen.c +++ b/kitty/screen.c @@ -1576,7 +1576,7 @@ screen_request_capabilities(Screen *self, char c, PyObject *q) { // Rendering {{{ static inline void update_line_data(Line *line, unsigned int dest_y, uint8_t *data) { - size_t base = dest_y * line->xnum * sizeof(GPUCell); + size_t base = sizeof(GPUCell) * dest_y * line->xnum; memcpy(data + base, line->gpu_cells, line->xnum * sizeof(GPUCell)); } diff --git a/kitty/shaders.c b/kitty/shaders.c index f8c0d3bd0..60433c328 100644 --- a/kitty/shaders.c +++ b/kitty/shaders.c @@ -65,7 +65,7 @@ copy_image_sub_data(GLuint src_texture_id, GLuint dest_texture_id, unsigned int copy_image_warned = true; log_error("WARNING: Your system's OpenGL implementation does not have glCopyImageSubData, falling back to a slower implementation"); } - size_t sz = width * height * num_levels; + size_t sz = (size_t)width * height * num_levels; pixel *src = malloc(sz * sizeof(pixel)); if (src == NULL) { fatal("Out of memory."); } glBindTexture(GL_TEXTURE_2D_ARRAY, src_texture_id); @@ -334,7 +334,7 @@ cell_prepare_to_render(ssize_t vao_idx, ssize_t gvao_idx, Screen *screen, GLfloa } if (screen->reload_all_gpu_data || screen_resized || screen_is_selection_dirty(screen)) { - sz = screen->lines * screen->columns; + sz = (size_t)screen->lines * screen->columns; address = alloc_and_map_vao_buffer(vao_idx, sz, selection_buffer, GL_STREAM_DRAW, GL_WRITE_ONLY); screen_apply_selection(screen, address, sz); unmap_vao_buffer(vao_idx, selection_buffer); address = NULL;