summaryrefslogtreecommitdiff
path: root/bfd/bfdio.c
diff options
context:
space:
mode:
authorAlan Modra <amodra@bigpond.net.au>2009-05-24 11:47:27 +0000
committerAlan Modra <amodra@bigpond.net.au>2009-05-24 11:47:27 +0000
commit56b1475f9d826125f837ee40d76587744ae0ab10 (patch)
tree9f6ef1be0ac53a342f399d2b839a9758e9517db7 /bfd/bfdio.c
parent05c0c4e5ae1617e1ae8242fee5debcb106662ffe (diff)
downloadbinutils-redhat-56b1475f9d826125f837ee40d76587744ae0ab10.tar.gz
* bfdio.c (bfd_seek): Formatting. Ensure newly allocated memory
for BFD_IN_MEMORY is cleared. (bfd_bwrite): Zero excess memory allocated.
Diffstat (limited to 'bfd/bfdio.c')
-rw-r--r--bfd/bfdio.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/bfd/bfdio.c b/bfd/bfdio.c
index d3a295c214..16bbf03a69 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