Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/powerpc/stand/mkbootimage PR/50685: David Binderman...
details: https://anonhg.NetBSD.org/src/rev/b040cce3f303
branches: trunk
changeset: 343063:b040cce3f303
user: christos <christos%NetBSD.org@localhost>
date: Thu Jan 21 17:14:05 2016 +0000
description:
PR/50685: David Binderman: fix memory leak
diffstat:
sys/arch/powerpc/stand/mkbootimage/mkbootimage.c | 17 +++++++++--------
1 files changed, 9 insertions(+), 8 deletions(-)
diffs (80 lines):
diff -r 6eb16c5a6c29 -r b040cce3f303 sys/arch/powerpc/stand/mkbootimage/mkbootimage.c
--- a/sys/arch/powerpc/stand/mkbootimage/mkbootimage.c Thu Jan 21 17:00:23 2016 +0000
+++ b/sys/arch/powerpc/stand/mkbootimage/mkbootimage.c Thu Jan 21 17:14:05 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: mkbootimage.c,v 1.18 2014/04/22 21:37:52 phx Exp $ */
+/* $NetBSD: mkbootimage.c,v 1.19 2016/01/21 17:14:05 christos Exp $ */
/*-
* Copyright (c) 2007 The NetBSD Foundation, Inc.
@@ -336,7 +336,7 @@
lseek(prep_fd, 0x400, SEEK_SET);
/* Copy boot image */
- elf_img = (unsigned char *)malloc(elf_img_len);
+ elf_img = malloc(elf_img_len);
if (!elf_img)
errx(3, "Can't malloc: %s", strerror(errno));
if (read(elf_fd, elf_img, elf_img_len) != elf_img_len)
@@ -347,7 +347,7 @@
if (inkernflag) {
/* Copy kernel */
- kern_img = (unsigned char *)malloc(kern_stat.st_size);
+ kern_img = malloc(kern_stat.st_size);
if (kern_img == NULL)
errx(3, "Can't malloc: %s", strerror(errno));
@@ -502,7 +502,7 @@
lseek(rs6000_fd, 0x400, SEEK_SET);
/* Copy boot image */
- elf_img = (unsigned char *)malloc(elf_img_len);
+ elf_img = malloc(elf_img_len);
if (!elf_img)
errx(3, "Can't malloc: %s", strerror(errno));
if (read(elf_fd, elf_img, elf_img_len) != elf_img_len)
@@ -516,7 +516,7 @@
lseek(rs6000_fd, elf_pad, SEEK_CUR);
/* Copy kernel */
- kern_img = (unsigned char *)malloc(kern_stat.st_size);
+ kern_img = malloc(kern_stat.st_size);
if (kern_img == NULL)
errx(3, "Can't malloc: %s", strerror(errno));
@@ -735,7 +735,7 @@
bebox_write_header(bebox_fd, elf_img_len, kern_stat.st_size);
/* Copy kernel */
- kern_img = (unsigned char *)malloc(kern_stat.st_size);
+ kern_img = malloc(kern_stat.st_size);
if (kern_img == NULL)
errx(3, "Can't malloc: %s", strerror(errno));
@@ -786,7 +786,7 @@
toff = bebox_write_header(bebox_fd, elf_img_len, tmp);
/* Copy boot image */
- elf_img = (unsigned char *)malloc(elf_img_len);
+ elf_img = malloc(elf_img_len);
if (!elf_img)
errx(3, "Can't malloc: %s", strerror(errno));
if (read(elf_fd, elf_img, elf_img_len) != elf_img_len)
@@ -802,7 +802,7 @@
/* Now go back and write in the block header */
endoff = lseek(bebox_fd, 0, SEEK_END);
lseek(bebox_fd, 0, SEEK_SET);
- header_img = (unsigned char *)malloc(BEBOX_HEADER_SIZE);
+ header_img = malloc(BEBOX_HEADER_SIZE);
if (!header_img)
errx(3, "Can't malloc: %s", strerror(errno));
memset(header_img, 0, BEBOX_HEADER_SIZE);
@@ -837,6 +837,7 @@
write(bebox_fd, header_img, flength - endoff);
close(bebox_fd);
+ free(header_img);
return 0;
}
Home |
Main Index |
Thread Index |
Old Index