mirror of
https://github.com/kovidgoyal/kitty.git
synced 2026-11-19 14:45:29 +00:00
Make CodeQL happy
This commit is contained in:
parent
bdafa913bf
commit
1b2ea883b0
1 changed files with 6 additions and 3 deletions
9
glfw/wl_client_side_decorations.c
vendored
9
glfw/wl_client_side_decorations.c
vendored
|
|
@ -132,8 +132,10 @@ create_shadow_tile(_GLFWwindow *window) {
|
|||
free(st.data);
|
||||
st.data = NULL;
|
||||
if (!mask) return margin;
|
||||
st.data = malloc(sizeof(st.data[0]) * st.stride * st.stride);
|
||||
if (st.data)
|
||||
// Fill a local buffer and only publish it to st.data once complete, this
|
||||
// also avoids a false positive use-after-free warning from CodeQL
|
||||
uint32_t *data = malloc(sizeof(data[0]) * st.stride * st.stride);
|
||||
if (data)
|
||||
for (size_t y = 0; y < st.stride; y++)
|
||||
for (size_t x = 0; x < st.stride; x++) {
|
||||
double alpha = mask[y * st.stride + x];
|
||||
|
|
@ -148,9 +150,10 @@ create_shadow_tile(_GLFWwindow *window) {
|
|||
if (dx > 0 && dy > 0) distance = radius - hypot(dx, dy);
|
||||
double coverage = fmax(0, fmin(1, distance / feather));
|
||||
alpha *= coverage * coverage * (3 - 2 * coverage);
|
||||
st.data[y * st.stride + x] = ((uint32_t)(alpha * 255)) << 24;
|
||||
data[y * st.stride + x] = ((uint32_t)(alpha * 255)) << 24;
|
||||
}
|
||||
free(mask);
|
||||
st.data = data;
|
||||
return margin;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue