2009-06-05 Doug Kwan <dougkwan@google.com>
[deliverable/binutils-gdb.git] / bfd / bfdio.c
index d3a295c214d7503a75d4055d34f26dc7b4128539..16bbf03a6970b619ed3d57dcb008f120a98c399c 100644 (file)
@@ -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
This page took 0.024769 seconds and 4 git commands to generate.