Skip to contentSkip to conversation

Btrfs-progs: fsck: fix memory leak and unnecessary call to free

PATCH New Rakesh Pandit 1 participant 1 message Mar 15, 2014 Btrfs file system

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Btrfs-progs: fsck: fix memory leak and unnecessary call to free

Free already allocated memory to item1_data if malloc fails for item2_data in swap_values. Seems to be a typo from commit 70749a77.

---
 cmds-check.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
cmds-check.c +1 -1
index d1cafe1..60708d0 100644
@@ -2380,7 +2380,7 @@ static int swap_values(struct btrfs_root *root, struct btrfs_path *path,
 			return -ENOMEM;
 		item2_data = malloc(item2_size);
 		if (!item2_data) {
-			free(item2_data);
+			free(item1_data);
 			return -ENOMEM;
 		}
 
Signature · 1 line
1.8.5.3