提交 0dc84c34 编写于 作者: M Michal Privoznik

nss: Don't leak memory on parse error

If yajl_parse() fails, we try to print an error message. For
that, yajl_get_error() is used. However, its documentation say
that caller is also responsible for freeing the memory it
allocates by using yajl_free_error().
Signed-off-by: NMichal Privoznik <mprivozn@redhat.com>
Reviewed-by: NDaniel P. Berrangé <berrange@redhat.com>
上级 fd21db65
......@@ -399,9 +399,10 @@ findLeases(const char *file,
if (yajl_parse(parser, (const unsigned char *)line, rv) !=
yajl_status_ok) {
ERROR("Parse failed %s",
yajl_get_error(parser, 1,
(const unsigned char*)line, rv));
unsigned char *err = yajl_get_error(parser, 1,
(const unsigned char*)line, rv);
ERROR("Parse failed %s", (const char *) err);
yajl_free_error(parser, err);
goto cleanup;
}
}
......
......@@ -252,9 +252,10 @@ findMACs(const char *file,
if (yajl_parse(parser, (const unsigned char *)line, rv) !=
yajl_status_ok) {
ERROR("Parse failed %s",
yajl_get_error(parser, 1,
(const unsigned char*)line, rv));
unsigned char *err = yajl_get_error(parser, 1,
(const unsigned char*)line, rv);
ERROR("Parse failed %s", (const char *) err);
yajl_free_error(parser, err);
goto cleanup;
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册