diff mbox

[v3,04/21] container: don't leak container reference

Message ID 20170316092121.25672-5-marcandre.lureau@redhat.com
State New
Headers show

Commit Message

Marc-André Lureau March 16, 2017, 9:21 a.m. UTC
object_property_add_child() references the child, unref it after to
avoid ref leaks.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 qom/container.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Philippe Mathieu-Daudé April 11, 2017, 2:53 a.m. UTC | #1
On 03/16/2017 06:21 AM, Marc-André Lureau wrote:
> object_property_add_child() references the child, unref it after to
> avoid ref leaks.
>
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>

Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>

> ---
>  qom/container.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/qom/container.c b/qom/container.c
> index c9eb49b01e..f6ccaf7ea7 100644
> --- a/qom/container.c
> +++ b/qom/container.c
> @@ -40,6 +40,7 @@ Object *container_get(Object *root, const char *path)
>          if (!child) {
>              child = object_new("container");
>              object_property_add_child(obj, parts[i], child, NULL);
> +            object_unref(child);
>          }
>      }
>
>
diff mbox

Patch

diff --git a/qom/container.c b/qom/container.c
index c9eb49b01e..f6ccaf7ea7 100644
--- a/qom/container.c
+++ b/qom/container.c
@@ -40,6 +40,7 @@  Object *container_get(Object *root, const char *path)
         if (!child) {
             child = object_new("container");
             object_property_add_child(obj, parts[i], child, NULL);
+            object_unref(child);
         }
     }