Skip to content

Commit

Permalink
Quick and dirty fix for resource data alignment.
Browse files Browse the repository at this point in the history
Probably fixes #12 and #26
  • Loading branch information
tc-hib authored and akavel committed Dec 10, 2020
1 parent f8b6563 commit 9547050
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
9 changes: 9 additions & 0 deletions binutil/writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,14 @@ func (w *Writer) WriteFromSized(r SizedReader) {
}
var n int64
n, w.Err = io.CopyN(w.W, r, r.Size())
if w.Err != nil {
return
}
aligned := (n-1)&^7 + 8
if aligned > n {
var z [8]byte
w.W.Write(z[:aligned-n])
n = aligned
}
w.Offset += uint32(n)
}
2 changes: 1 addition & 1 deletion coff/coff.go
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ func freezeCommon2(v reflect.Value, offset *uint32) error {
}
vv, ok := v.Interface().(Sizer)
if ok {
*offset += uint32(vv.Size())
*offset += uint32((vv.Size()-1)&^7 + 8)
return binutil.WALK_SKIP
}
return nil
Expand Down

0 comments on commit 9547050

Please sign in to comment.