Skip to content

Commit

Permalink
backend: driver: fix memory leak (randr_version not freed)
Browse files Browse the repository at this point in the history
Fixes the following memory leaks reported by valgrind:

    32 bytes in 1 blocks are definitely lost in loss record 15 of 111
       at 0x483577F: malloc (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so)
       by 0x49DB0DD: ??? (in /usr/lib/x86_64-linux-gnu/libxcb.so.1.1.0)
       by 0x49D8FB4: ??? (in /usr/lib/x86_64-linux-gnu/libxcb.so.1.1.0)
       by 0x49DA63E: ??? (in /usr/lib/x86_64-linux-gnu/libxcb.so.1.1.0)
       by 0x49DA751: xcb_wait_for_reply (in /usr/lib/x86_64-linux-gnu/libxcb.so.1.1.0)
       by 0x14B16F: detect_driver (driver.c:20)
       by 0x119949: session_init (compton.c:1879)
       by 0x11AEF0: main (compton.c:2285)

    32 bytes in 1 blocks are definitely lost in loss record 16 of 111
       at 0x483577F: malloc (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so)
       by 0x49DB0DD: ??? (in /usr/lib/x86_64-linux-gnu/libxcb.so.1.1.0)
       by 0x49D8FB4: ??? (in /usr/lib/x86_64-linux-gnu/libxcb.so.1.1.0)
       by 0x49DA63E: ??? (in /usr/lib/x86_64-linux-gnu/libxcb.so.1.1.0)
       by 0x49DA751: xcb_wait_for_reply (in /usr/lib/x86_64-linux-gnu/libxcb.so.1.1.0)
       by 0x14B16F: detect_driver (driver.c:20)
       by 0x11795E: redir_start (compton.c:1202)
       by 0x115C76: paint_preprocess (compton.c:629)
       by 0x1182BD: _draw_callback (compton.c:1380)
       by 0x1184D0: draw_callback (compton.c:1426)
       by 0x49BF292: ev_invoke_pending (in /usr/lib/x86_64-linux-gnu/libev.so.4.0.0)
       by 0x49C3344: ev_run (in /usr/lib/x86_64-linux-gnu/libev.so.4.0.0)

Also, free(randr_version) in the error path as well.
  • Loading branch information
liskin authored and yshui committed Sep 21, 2019
1 parent be8bb3d commit c5f12be
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/backend/driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ enum driver detect_driver(xcb_connection_t *c, backend_t *backend_data, xcb_wind
c, xcb_randr_get_providers(c, window), NULL);
if (r == NULL) {
log_warn("Failed to get RANDR providers");
free(randr_version);
return 0;
}

Expand Down Expand Up @@ -57,6 +58,7 @@ enum driver detect_driver(xcb_connection_t *c, backend_t *backend_data, xcb_wind
}
free(r);
}
free(randr_version);

// If the backend supports driver detection, use that as well
if (backend_data && backend_data->ops->detect_driver) {
Expand Down

0 comments on commit c5f12be

Please sign in to comment.