Skip to content
Snippets Groups Projects
Commit 6ec4d431 authored by Deucе's avatar Deucе :ok_hand_tone4:
Browse files

Fix some highly unlikely memory leaks

- Ensure last is cleared even if we manage external scaling without Xrender
- Free the bitmap rectangle in the same situation
- Make a copy of x_internal_scaling so it's used consistently
  (not mutex protected, and accessed from multiple threads)
parent 34747a84
Branches
Tags
1 merge request!463MRC mods by Codefenix (2024-10-20)
Pipeline #4427 failed
...@@ -1203,6 +1203,7 @@ local_draw_rect(struct rectlist *rect) ...@@ -1203,6 +1203,7 @@ local_draw_rect(struct rectlist *rect)
int w, h; int w, h;
int dw, dh; int dw, dh;
uint32_t *source_data; uint32_t *source_data;
bool internal_scaling = x_internal_scaling;
if (x_cvstat.scrnwidth != rect->rect.width || x_cvstat.scrnheight != rect->rect.height || xim == NULL) { if (x_cvstat.scrnwidth != rect->rect.width || x_cvstat.scrnheight != rect->rect.height || xim == NULL) {
bitmap_drv_free_rect(rect); bitmap_drv_free_rect(rect);
...@@ -1222,7 +1223,7 @@ local_draw_rect(struct rectlist *rect) ...@@ -1222,7 +1223,7 @@ local_draw_rect(struct rectlist *rect)
bitmap_drv_free_rect(rect); bitmap_drv_free_rect(rect);
return; return;
} }
if (x_internal_scaling) { if (internal_scaling) {
source = do_scale(rect, w, h); source = do_scale(rect, w, h);
bitmap_drv_free_rect(rect); bitmap_drv_free_rect(rect);
if (source == NULL) if (source == NULL)
...@@ -1314,7 +1315,7 @@ local_draw_rect(struct rectlist *rect) ...@@ -1314,7 +1315,7 @@ local_draw_rect(struct rectlist *rect)
} }
idx++; idx++;
} }
if (x_internal_scaling) { if (internal_scaling) {
/* This line was changed */ /* This line was changed */
// TODO: Previously this did one update per display line... // TODO: Previously this did one update per display line...
if (last && cright >= 0 && (cbottom != y || y == source->h - 1)) { if (last && cright >= 0 && (cbottom != y || y == source->h - 1)) {
...@@ -1327,6 +1328,8 @@ local_draw_rect(struct rectlist *rect) ...@@ -1327,6 +1328,8 @@ local_draw_rect(struct rectlist *rect)
} }
} }
} }
if (!internal_scaling)
bitmap_drv_free_rect(rect);
// TODO: We really only need to do this once after changing resolution... // TODO: We really only need to do this once after changing resolution...
if (xoff > 0 || yoff > 0) { if (xoff > 0 || yoff > 0) {
...@@ -1335,7 +1338,7 @@ local_draw_rect(struct rectlist *rect) ...@@ -1335,7 +1338,7 @@ local_draw_rect(struct rectlist *rect)
x11.XFillRectangle(dpy, win, gc, xoff+xim->width, yoff, w, yoff + xim->height); x11.XFillRectangle(dpy, win, gc, xoff+xim->width, yoff, w, yoff + xim->height);
x11.XFillRectangle(dpy, win, gc, 0, yoff + xim->height, w, h); x11.XFillRectangle(dpy, win, gc, 0, yoff + xim->height, w, h);
} }
if (x_internal_scaling || xrender_found == false) { if (internal_scaling || xrender_found == false) {
if (last == NULL) if (last == NULL)
x11.XPutImage(dpy, win, gc, xim, 0, 0, xoff, yoff, cleft, ctop); x11.XPutImage(dpy, win, gc, xim, 0, 0, xoff, yoff, cleft, ctop);
else { else {
...@@ -1344,12 +1347,11 @@ local_draw_rect(struct rectlist *rect) ...@@ -1344,12 +1347,11 @@ local_draw_rect(struct rectlist *rect)
} }
} }
else { else {
#ifdef WITH_XRENDER
bitmap_drv_free_rect(rect);
if (last != NULL) { if (last != NULL) {
release_buffer(last); release_buffer(last);
last = NULL; last = NULL;
} }
#ifdef WITH_XRENDER
x11.XPutImage(dpy, xrender_pm, gc, xim, 0, 0, 0, 0, dw, dh); x11.XPutImage(dpy, xrender_pm, gc, xim, 0, 0, 0, 0, dw, dh);
x11.XRenderComposite(dpy, PictOpSrc, xrender_src_pict, 0, xrender_dst_pict, x11.XRenderComposite(dpy, PictOpSrc, xrender_src_pict, 0, xrender_dst_pict,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment