From 9a47f7bf7188d87afb46fddbac819436c1783ec2 Mon Sep 17 00:00:00 2001 From: Christian Helmuth Date: Wed, 29 Jun 2022 16:57:23 +0200 Subject: [PATCH] sandbox: prevent non-empty list model on destruction The parent-provides model is destroyed if no node is found in the configuration, which resulted in Warning: list model not empty at destruction time and leaking memory for the allocated nodes. The commit now explicitly empties the list model in the destructor of ~Parent_provides_model. Note, the case is implicitly tested in pkg/test-init by step "denial of forwarded session request" and . Thanks to Peter for reporting this issue. Fixes #4547 --- repos/os/recipes/pkg/test-init/runtime | 1 + repos/os/src/lib/sandbox/config_model.h | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/repos/os/recipes/pkg/test-init/runtime b/repos/os/recipes/pkg/test-init/runtime index 3bf01e2601..74fd529b5d 100644 --- a/repos/os/recipes/pkg/test-init/runtime +++ b/repos/os/recipes/pkg/test-init/runtime @@ -5,6 +5,7 @@ child "test-init" exited with exit value 0 + list model not empty at destruction time diff --git a/repos/os/src/lib/sandbox/config_model.h b/repos/os/src/lib/sandbox/config_model.h index 30d14a7430..5a007970fe 100644 --- a/repos/os/src/lib/sandbox/config_model.h +++ b/repos/os/src/lib/sandbox/config_model.h @@ -73,6 +73,11 @@ struct Sandbox::Parent_provides_model : Noncopyable _alloc(alloc), _verbose(verbose), _factory(factory) { } + ~Parent_provides_model() + { + update_from_xml(Xml_node("")); + } + void update_from_xml(Xml_node const &xml) { bool first_log = true;