# link/wasm: fix writing past the end of debug info buffer · gitcafe/zig

[View on GitCafe](https://git.cafe/gitcafe/zig/commit/6bf529dc381cb2f5a83c5f9e303ffdab7779ac4d)

Repository: [gitcafe/zig](https://git.cafe/gitcafe/zig)

Visibility: public

Requested revision: 6bf529dc381cb2f5a83c5f9e303ffdab7779ac4d

Requested commit: 6bf529dc381cb2f5a83c5f9e303ffdab7779ac4d

Commit: 6bf529dc381cb2f5a83c5f9e303ffdab7779ac4d

Tree: 260738d5e702421ba7f368f3bfd31898ddc35367

Author: Andrew Kelley

Committer: Andrew Kelley

## Message

```
link/wasm: fix writing past the end of debug info buffer

The function `writeDbgInfoNopsBuffered` was based on the function
`pwriteDbgInfoNops`, originally written by me, and then modified to
write to a memory buffer instead of an open file. When writing to a
file, any extra bytes beyond the end of the file extend the size of
the file, and the function body of `pwriteDbgInfoNops` takes advantage
of this when `next_padding_bytes` causes the write to go beyond the
end of the file. However, when writing to a memory buffer, the
underlying array list must be expanded if the write would cause the
buffer to expand.

```

## Parents

- [3c3bc5af29a5fcd1daaf8d8d39625c7b505e80bf](https://git.cafe/gitcafe/zig/commit/3c3bc5af29a5fcd1daaf8d8d39625c7b505e80bf?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zig/tree/6bf529dc381cb2f5a83c5f9e303ffdab7779ac4d?format=markdown)
