[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[RP] [PATCH] Free discarded sbuf in hook_add()
From: |
Repolho |
Subject: |
[RP] [PATCH] Free discarded sbuf in hook_add() |
Date: |
Wed, 7 Aug 2013 14:30:58 -0300 |
User-agent: |
Mutt/1.5.21 (2010-09-15) |
Note: this is a very insignificant leak due to how rarely addhook would be
called in everyday usage, but it's a leak nonetheless, so I thought I'd mention
it.
hook.c:hook_add() fails to free sbuf containing command (allocated by
actions.c:cmd_addhook()), when that command is already present in the hook,
resulting in a leak every time the user tries to re-add the same command to a
hook.
To reproduce, add a command to a hook twice, for example, by running:
$ ratpoison -c "addhook quit abort"; !#
which results in (taken from valgrind's log):
46 (40 direct, 6 indirect) bytes in 1 blocks are definitely lost in loss record
73 of 200
at 0x4C2C04B: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
by 0x41BDCE: xmalloc (main.c:74)
by 0x41F625: sbuf_new (sbuf.c:30)
by 0x4106A4: cmd_addhook (actions.c:5218)
by 0x40A882: command (actions.c:2557)
by 0x40AA70: cmd_colon (actions.c:2597)
by 0x40A882: command (actions.c:2557)
by 0x415B22: handle_key (events.c:423)
by 0x415BD8: key_press (events.c:459)
by 0x416663: delegate_event (events.c:840)
by 0x416AF5: listen_for_events (events.c:1008)
by 0x41D187: main (main.c:749)
The attached patch fixes the issue. It was generated over the latest git,
v1.4.6-48-gb02d855.
addhook_leak.patch
Description: Text Data
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [RP] [PATCH] Free discarded sbuf in hook_add(),
Repolho <=