mirror of
https://github.com/kovidgoyal/kitty.git
synced 2026-05-13 08:26:56 +00:00
Make CodeQL happy
This commit is contained in:
parent
b3a0a9907f
commit
4b38818dca
5 changed files with 22 additions and 20 deletions
|
|
@ -235,7 +235,7 @@ typedef struct Canvas {
|
|||
} Canvas;
|
||||
|
||||
static void
|
||||
fill_canvas(Canvas *self, int byte) { memset(self->mask, byte, self->width * self->height * sizeof(self->mask[0])); }
|
||||
fill_canvas(Canvas *self, int byte) { memset(self->mask, byte, sizeof(self->mask[0]) * self->width * self->height); }
|
||||
|
||||
static void
|
||||
append_hole(Canvas *self, Range hole) {
|
||||
|
|
@ -1581,7 +1581,7 @@ START_ALLOW_CASE_RANGE
|
|||
SH(L'🮖', .xnum=4, .ynum=4, .invert=true);
|
||||
SH(L'🮗', .xnum=1, .ynum=4, .invert=true);
|
||||
#define M(ch, corner) SB(ch, corner_triangle(c, corner)); \
|
||||
memcpy(ss.mask, canvas.mask, canvas.width * canvas.height * sizeof(canvas.mask[0])); \
|
||||
memcpy(ss.mask, canvas.mask, sizeof(canvas.mask[0]) * canvas.width * canvas.height); \
|
||||
fill_canvas(&canvas, 0); shade(&canvas, (Shade){.xnum=12}); \
|
||||
apply_mask(&canvas, ss.mask); break;
|
||||
M(L'🮜', TOP_LEFT);
|
||||
|
|
|
|||
|
|
@ -135,7 +135,7 @@ static void
|
|||
display_rgba_data(const pixel *b, unsigned width, unsigned height) {
|
||||
RAII_PyObject(m, PyImport_ImportModule("kitty.fonts.render"));
|
||||
RAII_PyObject(f, PyObject_GetAttrString(m, "show"));
|
||||
RAII_PyObject(data, PyMemoryView_FromMemory((char*)b, width * height * sizeof(b[0]), PyBUF_READ));
|
||||
RAII_PyObject(data, PyMemoryView_FromMemory((char*)b, (Py_ssize_t)width * height * sizeof(b[0]), PyBUF_READ));
|
||||
RAII_PyObject(ret, PyObject_CallFunction(f, "OII", data, width, height));
|
||||
if (ret == NULL) PyErr_Print();
|
||||
}
|
||||
|
|
@ -154,7 +154,7 @@ python_send_to_gpu(FontGroup *fg, sprite_index idx, pixel *buf) {
|
|||
if (0) dump_sprite(buf, fg->fcm.cell_width, fg->fcm.cell_height);
|
||||
unsigned int x, y, z;
|
||||
sprite_index_to_pos(idx, fg->sprite_tracker.xnum, fg->sprite_tracker.ynum, &x, &y, &z);
|
||||
const size_t sprite_size = fg->fcm.cell_width * fg->fcm.cell_height;
|
||||
const size_t sprite_size = (size_t)fg->fcm.cell_width * fg->fcm.cell_height;
|
||||
PyObject *ret = PyObject_CallFunction(python_send_to_gpu_impl, "IIIy#", x, y, z, buf, sprite_size * sizeof(buf[0]));
|
||||
if (ret == NULL) PyErr_Print();
|
||||
else Py_DECREF(ret);
|
||||
|
|
@ -834,8 +834,8 @@ effective_scale(RunFont rf) {
|
|||
static float
|
||||
scaled_cell_dimensions(RunFont rf, unsigned *width, unsigned *height) {
|
||||
float frac = effective_scale(rf);
|
||||
*width = (unsigned)ceil(frac * *width);
|
||||
*height = (unsigned)ceil(frac * *height);
|
||||
*width = (unsigned)ceilf(frac * *width);
|
||||
*height = (unsigned)ceilf(frac * *height);
|
||||
return frac;
|
||||
}
|
||||
|
||||
|
|
@ -956,7 +956,7 @@ map_scaled_decoration_geometry(DecorationGeometry sdg, Region src, Region dest)
|
|||
|
||||
static void
|
||||
render_scaled_decoration(FontCellMetrics unscaled_metrics, FontCellMetrics scaled_metrics, uint8_t *alpha_mask, pixel *output, Region src, Region dest) {
|
||||
memset(output, 0, unscaled_metrics.cell_width * (unscaled_metrics.cell_height + 1) * sizeof(output[0]));
|
||||
memset(output, 0, sizeof(output[0]) * unscaled_metrics.cell_width * (unscaled_metrics.cell_height + 1));
|
||||
unsigned src_limit = MIN(scaled_metrics.cell_height, src.bottom), dest_limit = MIN(unscaled_metrics.cell_height, dest.bottom);
|
||||
unsigned cell_width = MIN(scaled_metrics.cell_width, unscaled_metrics.cell_width);
|
||||
for (unsigned srcy = src.top, desty=dest.top; srcy < src_limit && desty < dest_limit; srcy++, desty++) {
|
||||
|
|
@ -972,13 +972,13 @@ render_decorations(FontGroup *fg, Region src, Region dest, FontCellMetrics scale
|
|||
if ((src.bottom == src.top) || (dest.bottom == dest.top)) return 0; // no overlap
|
||||
const FontCellMetrics unscaled_metrics = fg->fcm;
|
||||
scaled_metrics.cell_width = unscaled_metrics.cell_width;
|
||||
RAII_ALLOC(uint8_t, alpha_mask, malloc(scaled_metrics.cell_height * scaled_metrics.cell_width));
|
||||
RAII_ALLOC(pixel, buf, malloc(unscaled_metrics.cell_width * (unscaled_metrics.cell_height + 1) * sizeof(pixel)));
|
||||
RAII_ALLOC(uint8_t, alpha_mask, malloc((size_t)scaled_metrics.cell_height * scaled_metrics.cell_width));
|
||||
RAII_ALLOC(pixel, buf, malloc(sizeof(pixel) * unscaled_metrics.cell_width * (unscaled_metrics.cell_height + 1)));
|
||||
if (!alpha_mask || !buf) fatal("Out of memory");
|
||||
sprite_index ans = 0;
|
||||
bool is_underline = false; uint32_t underline_top = unscaled_metrics.cell_height, underline_bottom = 0;
|
||||
#define do_one(call) { \
|
||||
memset(alpha_mask, 0, scaled_metrics.cell_width * scaled_metrics.cell_height * sizeof(alpha_mask[0])); \
|
||||
memset(alpha_mask, 0, sizeof(alpha_mask[0]) * scaled_metrics.cell_width * scaled_metrics.cell_height); \
|
||||
DecorationGeometry sdg = call; \
|
||||
render_scaled_decoration(unscaled_metrics, scaled_metrics, alpha_mask, buf, src, dest); \
|
||||
sprite_index q = current_send_sprite_to_gpu(fg, buf, (DecorationMetadata){0}, scaled_metrics); \
|
||||
|
|
@ -1119,11 +1119,11 @@ load_hb_buffer(CPUCell *first_cpu_cell, GPUCell *first_gpu_cell, index_type num_
|
|||
static void
|
||||
render_filled_sprite(pixel *buf, unsigned num_glyphs, FontCellMetrics scaled_metrics, unsigned num_scaled_cells) {
|
||||
if (num_scaled_cells > num_glyphs) {
|
||||
memset(buf, 0xff, num_glyphs * scaled_metrics.cell_width * sizeof(buf[0]));
|
||||
memset(buf + num_glyphs * scaled_metrics.cell_width, 0, (num_scaled_cells - num_glyphs) * scaled_metrics.cell_width * sizeof(buf[0]));
|
||||
memset(buf, 0xff, sizeof(buf[0]) * num_glyphs * scaled_metrics.cell_width);
|
||||
memset(buf + num_glyphs * scaled_metrics.cell_width, 0, sizeof(buf[0]) * (num_scaled_cells - num_glyphs) * scaled_metrics.cell_width);
|
||||
for (unsigned y = 1; y < scaled_metrics.cell_height; y++) memcpy(
|
||||
buf + scaled_metrics.cell_width * num_scaled_cells * y, buf, scaled_metrics.cell_width * num_scaled_cells * sizeof(buf[0]));
|
||||
} else memset(buf, 0xff, num_glyphs * scaled_metrics.cell_height * scaled_metrics.cell_width * sizeof(buf[0]));
|
||||
buf + scaled_metrics.cell_width * num_scaled_cells * y, buf, sizeof(buf[0]) * scaled_metrics.cell_width * num_scaled_cells );
|
||||
} else memset(buf, 0xff, sizeof(buf[0]) * num_glyphs * scaled_metrics.cell_height * scaled_metrics.cell_width );
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
|||
|
|
@ -718,15 +718,17 @@ get_variation_as_string(Face *self) {
|
|||
if ((err = FT_Get_Var_Design_Coordinates(self->face, mm->num_axis, coords))) return NULL;
|
||||
RAII_ALLOC(char, buf, NULL);
|
||||
uint8_t tag[5];
|
||||
size_t pos = 0, sz = 0;
|
||||
size_t pos = 0, sz = 0, n, bufsz;
|
||||
for (FT_UInt i = 0; i < mm->num_axis; i++) {
|
||||
double val = coords[i] / 65536.0;
|
||||
tag_to_string(mm->axis[i].tag, tag);
|
||||
if (sz - pos < 32) {
|
||||
sz += 4096; buf = realloc(buf, sz); if (!buf) return NULL;
|
||||
}
|
||||
if ((long)val == val) pos += snprintf(buf + pos, sz - pos - 1, "%s=%ld,", tag, (long)val);
|
||||
else pos += snprintf(buf + pos, sz - pos - 1, "%s=%.4f,", tag, val);
|
||||
bufsz = sz - pos - 1;
|
||||
if ((long)val == val) n = snprintf(buf + pos, bufsz, "%s=%ld,", tag, (long)val);
|
||||
else n = snprintf(buf + pos, bufsz, "%s=%.4f,", tag, val);
|
||||
if (n < bufsz) pos += n;
|
||||
}
|
||||
char *ans = NULL;
|
||||
if (buf) {
|
||||
|
|
|
|||
|
|
@ -5285,7 +5285,7 @@ line_edge_colors(Screen *self, PyObject *a UNUSED) {
|
|||
|
||||
static PyObject*
|
||||
current_selections(Screen *self, PyObject *a UNUSED) {
|
||||
PyObject *ans = PyBytes_FromStringAndSize(NULL, self->lines * self->columns);
|
||||
PyObject *ans = PyBytes_FromStringAndSize(NULL, (Py_ssize_t)self->lines * self->columns);
|
||||
if (!ans) return NULL;
|
||||
screen_apply_selection(self, PyBytes_AS_STRING(ans), PyBytes_GET_SIZE(ans));
|
||||
return ans;
|
||||
|
|
|
|||
|
|
@ -119,7 +119,7 @@ copy_32bit_texture(GLuint old_texture, GLuint new_texture, GLenum texture_type)
|
|||
break;
|
||||
}
|
||||
glPixelStorei(GL_UNPACK_ALIGNMENT, 4);
|
||||
RAII_ALLOC(uint8_t, pixels, malloc(width * height * layers * 4));
|
||||
RAII_ALLOC(uint8_t, pixels, malloc((size_t)width * height * layers * 4u));
|
||||
if (!pixels) fatal("Out of memory");
|
||||
glGetTexImage(texture_type, 0, format, type, pixels);
|
||||
glBindTexture(texture_type, new_texture);
|
||||
|
|
@ -146,7 +146,7 @@ static void
|
|||
realloc_sprite_decorations_texture_if_needed(FONTS_DATA_HANDLE fg) {
|
||||
#define dm (sm->decorations_map)
|
||||
SpriteMap *sm = (SpriteMap*)fg->sprite_map;
|
||||
size_t current_capacity = dm.width * dm.height;
|
||||
size_t current_capacity = (size_t)dm.width * dm.height;
|
||||
if (dm.count < current_capacity && dm.texture_id) return;
|
||||
GLint new_capacity = dm.count + 256;
|
||||
GLint width = new_capacity, height = 1;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue