Skip to contentSkip to conversation

tools: fix memory leak in ibbp_dir_add() on buffer_from_file() failure

PATCH New [email protected] 1 participant 1 message May 16, 2025

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tools: fix memory leak in ibbp_dir_add() on buffer_from_file() failure

From: Anton Moryakov <[email protected]>

- Added buffer_delete(&manifest) before returning COMMAND_ERR.
- Prevents memory leak when file loading fails.

---
 tools/ifwitool.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
tools/ifwitool.c +3 -1
index 762161d769e..c17087963cd 100644
@@ -1741,8 +1741,10 @@ static enum ifwi_ret ibbp_dir_add(int type)
 	init_signed_pkg_info_ext(ext, 0, subparts[type].name);
 
 	/* Entry # 2 - IBBL */
-	if (buffer_from_file(&ibbl, param.file_name))
+	if (buffer_from_file(&ibbl, param.file_name)) {
+		buffer_delete(&manifest);
 		return COMMAND_ERR;
+	}
 
 	/* Entry # 3 - IBB */
 	alloc_buffer(&ibb, DUMMY_IBB_SIZE, "IBB");
Signature · 1 line
2.30.2