Skip to contentSkip to conversation

cmd: Fix potential memory leaks

PATCH In review Maks Mishin 2 participants 2 messages Feb 5, 2025 – Feb 11, 2025

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 cmd: Fix potential memory leaks

Dynamic memories, referenced by 'ptr' and 'res' is allocated
by calling function 'hexport_r' and lost when the function success returns.

---
 cmd/nvedit.c | 2 ++
 1 file changed, 2 insertions(+)
cmd/nvedit.c +2 -0
index 1f25980129..628f0a2935 100644
@@ -698,6 +698,7 @@ NXTARG:		;
 		}
 		sprintf(buf, "%zX", (size_t)len);
 		env_set("filesize", buf);
+		free(ptr);
 
 		return 0;
 	}
@@ -726,6 +727,7 @@ NXTARG:		;
 #endif
 	}
 	env_set_hex("filesize", len + offsetof(env_t, data));
+	free(res);
 
 	return 0;
 
Signature · 1 line
2.34.1