Skip to contentSkip to conversation

tools: Fix potential memory leak in aisimage.c

PATCH New [email protected] 1 participant 1 message Apr 18, 2025

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tools: Fix potential memory leak in aisimage.c

From: Maks Mishin <[email protected]>

The 'line' variable is dynamically allocated by getline() function during config file parsing but wasn't being freed before function exit, causing memory leak. This was detected by static analysis.

Add missing free() call before closing the file descriptor to prevent memory leak.

---
 tools/aisimage.c | 1 +
 1 file changed, 1 insertion(+)
tools/aisimage.c +1 -0
index b8b3ee32..6091c8d5 100644
@@ -346,6 +346,7 @@ static int aisimage_generate(struct image_tool_params *params,
 		}
 
 	}
+	free(line);
 	fclose(fd);
 
 	aishdr = ais_copy_image(params, aishdr);
Signature · 1 line
2.34.1