[CRIU] [PATCH 8/8] proc: don't leak memory
Andrey Vagin
avagin at openvz.org
Fri Oct 31 07:50:50 PDT 2014
CID 73370: Resource leak (RESOURCE_LEAK)
13. leaked_storage: Variable timer going out of scope leaks the storage it points to.
Signed-off-by: Andrey Vagin <avagin at openvz.org>
---
proc_parse.c | 19 ++++++++++---------
1 file changed, 10 insertions(+), 9 deletions(-)
diff --git a/proc_parse.c b/proc_parse.c
index a53408c..b9a8034 100644
--- a/proc_parse.c
+++ b/proc_parse.c
@@ -1619,30 +1619,31 @@ int parse_posix_timers(pid_t pid, struct proc_posix_timers_stat *args)
while (1) {
char pbuf[17]; /* 16 + eol */
+ if (!(s = breadline(&f)))
+ goto out;
+
timer = xzalloc(sizeof(struct proc_posix_timer));
if (timer == NULL)
goto err;
- if (!(s = breadline(&f)))
- goto out;
if (sscanf(s, "ID: %ld",
&timer->spt.it_id) != 1)
- goto err;
+ goto errf;
if (!(s = breadline(&f)))
- goto err;
+ goto errf;
if (sscanf(s, "signal: %d/%16s",
&timer->spt.si_signo, pbuf) != 2)
- goto err;
+ goto errf;
if (!(s = breadline(&f)))
- goto err;
+ goto errf;
if (sscanf(s, "notify: %6[a-z]/%3[a-z].%d\n",
sigpid, tidpid, &pid_t) != 3)
- goto err;
+ goto errf;
if (!(s = breadline(&f)))
- goto err;
+ goto errf;
if (sscanf(s, "ClockID: %d\n",
&timer->spt.clock_id) != 1)
- goto err;
+ goto errf;
timer->spt.sival_ptr = NULL;
if (sscanf(pbuf, "%p", &timer->spt.sival_ptr) != 1 &&
--
1.9.3
More information about the CRIU
mailing list