aboutsummaryrefslogtreecommitdiff
path: root/qom
diff options
context:
space:
mode:
authorChen Fan <chen.fan.fnst@cn.fujitsu.com>2014-08-18 14:46:34 +0800
committerMichael Tokarev <mjt@tls.msk.ru>2014-09-02 22:38:16 +0400
commit976620ac4018db142d82cd42bb7774f40290ce7e (patch)
tree2e3a3c21cd37c580b50e98b84cb94059ee1f222a /qom
parentb0e90181e4d7244a9466447703acdb2cdd7abdaa (diff)
qom/object.c, hmp.c: fix string_output_get_string() memory leak
string_output_get_string() uses g_string_free(str, false) to transfer the 'str' pointer to callers and never free it. Signed-off-by: Chen Fan <chen.fan.fnst@cn.fujitsu.com> Reviewed-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com> Reviewed-by: Hu Tao <hutao@cn.fujitsu.com> Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
Diffstat (limited to 'qom')
-rw-r--r--qom/object.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/qom/object.c b/qom/object.c
index 1b00831efc..79bd0cc474 100644
--- a/qom/object.c
+++ b/qom/object.c
@@ -938,14 +938,18 @@ int object_property_get_enum(Object *obj, const char *name,
{
StringOutputVisitor *sov;
StringInputVisitor *siv;
+ char *str;
int ret;
sov = string_output_visitor_new(false);
object_property_get(obj, string_output_get_visitor(sov), name, errp);
- siv = string_input_visitor_new(string_output_get_string(sov));
+ str = string_output_get_string(sov);
+ siv = string_input_visitor_new(str);
string_output_visitor_cleanup(sov);
visit_type_enum(string_input_get_visitor(siv),
&ret, strings, NULL, name, errp);
+
+ g_free(str);
string_input_visitor_cleanup(siv);
return ret;
@@ -956,13 +960,17 @@ void object_property_get_uint16List(Object *obj, const char *name,
{
StringOutputVisitor *ov;
StringInputVisitor *iv;
+ char *str;
ov = string_output_visitor_new(false);
object_property_get(obj, string_output_get_visitor(ov),
name, errp);
- iv = string_input_visitor_new(string_output_get_string(ov));
+ str = string_output_get_string(ov);
+ iv = string_input_visitor_new(str);
visit_type_uint16List(string_input_get_visitor(iv),
list, NULL, errp);
+
+ g_free(str);
string_output_visitor_cleanup(ov);
string_input_visitor_cleanup(iv);
}