[PATCH] Free cmdret returned by frestore() in cmd_sfrestore()
Repolho <[email protected]>
| Newsgroups | gmane.comp.window-managers.ratpoison.devel |
|---|---|
| Message-ID | <20130807172334.GA8065@darch> |
action.c:cmd_sfrestore() fails to free the cmdret* returned by frestore(), resulting in a leak for each screen, every time the function is used. To reproduce, run $ ratpoison -c "sfrestore $(ratpoison -c sfdump)" which results in (taken from valgrind's log): 16 bytes in 1 blocks are definitely lost in loss record 30 of 196 at 0x4C2C04B: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) by 0x41BD4A: xmalloc (main.c:74) by 0x406D8A: cmdret_new (actions.c:814) by 0x40FFD9: frestore (actions.c:5009) by 0x41152A: cmd_sfrestore (actions.c:5567) by 0x40A842: command (actions.c:2557) by 0x415CC6: execute_remote_command (events.c:502) by 0x415DF0: receive_command (events.c:567) by 0x415F5A: property_notify (events.c:601) by 0x4165C3: delegate_event (events.c:830) by 0x416A71: listen_for_events (events.c:1008) by 0x41D103: main (main.c:749) The attached patch fixes the issue. It was generated over the latest git, v1.4.6-48-gb02d855. _______________________________________________ Ratpoison-devel mailing list [email protected] https://lists.nongnu.org/mailman/listinfo/ratpoison-devel
sfrestore_leak.patch
(text/x-diff, 848 B)
diff -pdru ratpoison/src/actions.c ratpoison.build/src/actions.c
--- ratpoison/src/actions.c 2013-08-07 12:08:11.154005173 -0300
+++ ratpoison.build/src/actions.c 2013-08-07 12:27:40.928277504 -0300
@@ -5516,6 +5516,7 @@ cmd_sfrestore (int interactively UNUSED,
char *token;
char *ptr;
struct sbuf *buffer[num_screens];
+ cmdret *r;
/* initialize frameset-buffer for each screen */
for (j=0; j<num_screens; j++) {
@@ -5564,7 +5565,8 @@ cmd_sfrestore (int interactively UNUSED,
for (j=0; j<num_screens; j++) {
push_frame_undo (&screens[j]); /* fdump to stack */
/* FIXME: store RET_SUCCESS || RET_FAILURE for each screen and output it later */
- frestore (sbuf_get(buffer[j]), &screens[j]);
+ r = frestore (sbuf_get(buffer[j]), &screens[j]);
+ free(r);
/* clear buffer */
sbuf_free(buffer[j]);
}