summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Brown2025-04-29 17:28:03 +0200
committerMichael Brown2025-04-29 17:32:01 +0200
commita69c42dd9fa97024f572b431f6527d359568c23e (patch)
tree3740d6332757a52a60fed030452ad6c97a2723bb
parent[bofm] Remove userptr_t from BOFM table parsing and updating (diff)
downloadipxe-a69c42dd9fa97024f572b431f6527d359568c23e.tar.gz
ipxe-a69c42dd9fa97024f572b431f6527d359568c23e.tar.xz
ipxe-a69c42dd9fa97024f572b431f6527d359568c23e.zip
[image] Clear recorded replacement image immediately after consuming
If an embedded script uses "chain --replace", the embedded image will retain a reference to the replacement image in perpetuity. Fix by clearing any recorded replacement image immediately in image_exec(), instead of relying upon image_free() to drop the reference. Signed-off-by: Michael Brown <mcb30@ipxe.org>
-rw-r--r--src/core/image.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/core/image.c b/src/core/image.c
index a49ca7e1d..72885ec09 100644
--- a/src/core/image.c
+++ b/src/core/image.c
@@ -447,6 +447,10 @@ int image_exec ( struct image *image ) {
if ( replacement )
assert ( replacement->flags & IMAGE_REGISTERED );
+ /* Clear any recorded replacement image */
+ image_put ( image->replacement );
+ image->replacement = NULL;
+
err:
/* Unregister image if applicable */
if ( image->flags & IMAGE_AUTO_UNREGISTER )