From 5c93f09bedf7ff02efd6d82504bbc3c68df6d197 Mon Sep 17 00:00:00 2001 From: Alan Modra Date: Sun, 24 May 2009 11:47:27 +0000 Subject: * bfdio.c (bfd_seek): Formatting. Ensure newly allocated memory for BFD_IN_MEMORY is cleared. (bfd_bwrite): Zero excess memory allocated. --- bfd/bfdio.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'bfd/bfdio.c') diff --git a/bfd/bfdio.c b/bfd/bfdio.c index d3a295c..16bbf03 100644 --- a/bfd/bfdio.c +++ b/bfd/bfdio.c @@ -235,6 +235,8 @@ bfd_bwrite (const void *ptr, bfd_size_type size, bfd *abfd) bim->size = 0; return 0; } + if (newsize > bim->size) + memset (bim->buffer + bim->size, 0, newsize - bim->size); } } memcpy (bim->buffer + abfd->where, ptr, (size_t) size); @@ -342,8 +344,8 @@ bfd_seek (bfd *abfd, file_ptr position, int direction) if (abfd->where > bim->size) { - if ((abfd->direction == write_direction) || - (abfd->direction == both_direction)) + if (abfd->direction == write_direction + || abfd->direction == both_direction) { bfd_size_type newsize, oldsize; @@ -359,6 +361,7 @@ bfd_seek (bfd *abfd, file_ptr position, int direction) bim->size = 0; return -1; } + memset (bim->buffer + oldsize, 0, newsize - oldsize); } } else -- cgit v1.1