Skip to content

Commit

Permalink
Fix several memory leaks
Browse files Browse the repository at this point in the history
* src/event.c: expose_root: region is not freed
* backend/xrender/xrender.c:
    * bind_pixmap: the reply `r` is not freed
    * blur: reg_op_resized is not freed

Spotted-by: Samuel Hand <samuel.d.hand@gmail.com>
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
  • Loading branch information
yshui committed Sep 5, 2020
1 parent c4369ec commit c514547
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/backend/xrender/xrender.c
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ static bool blur(backend_t *backend_data, double opacity, void *ctx_,
if (!tmp_picture[0] || !tmp_picture[1]) {
log_error("Failed to build intermediate Picture.");
pixman_region32_fini(&reg_op);
pixman_region32_fini(&reg_op_resized);
return false;
}

Expand Down Expand Up @@ -244,6 +245,7 @@ static bool blur(backend_t *backend_data, double opacity, void *ctx_,
xcb_render_free_picture(c, tmp_picture[0]);
xcb_render_free_picture(c, tmp_picture[1]);
pixman_region32_fini(&reg_op);
pixman_region32_fini(&reg_op_resized);
return true;
}

Expand All @@ -268,6 +270,8 @@ bind_pixmap(backend_t *base, xcb_pixmap_t pixmap, struct xvisual_info fmt, bool
x_create_picture_with_visual_and_pixmap(base->c, fmt.visual, pixmap, 0, NULL);
img->owned = owned;
img->visual = fmt.visual;
free(r);

if (img->pict == XCB_NONE) {
free(img);
return NULL;
Expand Down
1 change: 1 addition & 0 deletions src/event.c
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,7 @@ static inline void expose_root(session_t *ps, const rect_t *rects, int nrects) {
region_t region;
pixman_region32_init_rects(&region, rects, nrects);
add_damage(ps, &region);
pixman_region32_fini(&region);
}

static inline void ev_expose(session_t *ps, xcb_expose_event_t *ev) {
Expand Down

0 comments on commit c514547

Please sign in to comment.