More code scanning warning fixes

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

View File

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

View File

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

View File

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