Thread (24 messages) 24 messages, 3 authors, 2011-11-02
STALE5343d

[PATCH 17/19] bitmap_fd_read(): fix memory leak

From: <hidden>
Date: 2011-11-01 15:09:33
Subsystem: the rest · Maintainer: Linus Torvalds

From: Jes Sorensen <redacted>

Signed-off-by: Jes Sorensen <redacted>
---
 bitmap.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/bitmap.c b/bitmap.c
index 2e1ecda..d02f16e 100644
--- a/bitmap.c
+++ b/bitmap.c
@@ -147,6 +147,7 @@ bitmap_info_t *bitmap_fd_read(int fd, int brief)
 		fprintf(stderr, Name ": failed to allocate %zd bytes\n",
 				sizeof(*info));
 #endif
+		free(buf);
 		return NULL;
 	}
 
@@ -154,6 +155,7 @@ bitmap_info_t *bitmap_fd_read(int fd, int brief)
 		fprintf(stderr, Name ": failed to read superblock of bitmap "
 			"file: %s\n", strerror(errno));
 		free(info);
+		free(buf);
 		return NULL;
 	}
 	memcpy(&info->sb, buf, sizeof(info->sb));
@@ -198,6 +200,7 @@ bitmap_info_t *bitmap_fd_read(int fd, int brief)
 		total_bits = read_bits;
 	}
 out:
+	free(buf);
 	info->total_bits = total_bits;
 	info->dirty_bits = dirty_bits;
 	return info;
-- 
1.7.6.4
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help