Commit 0e0a3989 authored by Andrey Vagin's avatar Andrey Vagin Committed by Pavel Emelyanov

proc: fix memory leak

timer is not freed in case of eof.

CID 1042301 (#1 of 1): Resource leak (RESOURCE_LEAK)
15. leaked_storage: Variable timer going out of scope leaks the storage it points to.
Signed-off-by: 's avatarAndrey Vagin <avagin@openvz.org>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent 071b940a
...@@ -1195,6 +1195,7 @@ int parse_posix_timers(pid_t pid, struct proc_posix_timers_stat *args) ...@@ -1195,6 +1195,7 @@ int parse_posix_timers(pid_t pid, struct proc_posix_timers_stat *args)
&timer->spt.clock_id); &timer->spt.clock_id);
if (ret != 7) { if (ret != 7) {
ret = 0; ret = 0;
xfree(timer);
if (feof(file)) if (feof(file))
goto out; goto out;
goto err; goto err;
...@@ -1221,7 +1222,6 @@ int parse_posix_timers(pid_t pid, struct proc_posix_timers_stat *args) ...@@ -1221,7 +1222,6 @@ int parse_posix_timers(pid_t pid, struct proc_posix_timers_stat *args)
args->timer_n++; args->timer_n++;
} }
err: err:
xfree(timer);
while (!list_empty(&args->timers)) { while (!list_empty(&args->timers)) {
timer = list_first_entry(&args->timers, struct proc_posix_timer, list); timer = list_first_entry(&args->timers, struct proc_posix_timer, list);
list_del(&timer->list); list_del(&timer->list);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment