[Concept,20/33] boot: Replace the current cedit expo on reload

Message ID 20260416023021.626949-21-sjg@u-boot.org
State New
Headers
Series Fix memory leaks and test pollution in sandbox tests |

Commit Message

Simon Glass April 16, 2026, 2:29 a.m. UTC
  From: Simon Glass <sjg@chromium.org>

The 'cedit load' command builds a new expo and stashes the pointer in
cur_exp, overwriting any previous one without freeing it. When
'cedit run' is successful, the expo is destroyed, but on failure (or
when a test inspects cur_exp and never calls 'cedit run' again) the
previous expo lingers and leaks every scene, string and object it owns,
about 20 KB per cedit test.

Destroy any current expo before replacing it on reload.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 cmd/cedit.c | 2 ++
 1 file changed, 2 insertions(+)
  

Patch

diff --git a/cmd/cedit.c b/cmd/cedit.c
index fc477291be8..bcd75fdb771 100644
--- a/cmd/cedit.c
+++ b/cmd/cedit.c
@@ -62,6 +62,8 @@  static int do_cedit_load(struct cmd_tbl *cmdtp, int flag, int argc,
 		return CMD_RET_FAILURE;
 	}
 
+	if (cur_exp)
+		expo_destroy(cur_exp);
 	cur_exp = exp;
 
 	return 0;