# fix argsAlloc buffer size · gitcafe/zig

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

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

Visibility: public

Requested revision: fedff060790733b85582b733cfea9fefb168deb6

Requested commit: fedff060790733b85582b733cfea9fefb168deb6

Commit: fedff060790733b85582b733cfea9fefb168deb6

Tree: 2b5487f551ce91c05741fddf12a90d3ef4e46859

Author: Jean Dao

Committer: Veikka Tuominen

## Message

```
fix argsAlloc buffer size

The buffer `buf` contains N (= `slice_sizes.len`) slices followed by the
N null-terminated arguments. The N null-terminated arguments are stored
in the `contents` array list. Thus, `buf` size should be:
    @sizeOf([]u8) * slice_sizes.len + contents_slice.len

Instead of:
    @sizeOf([]u8) * slice_sizes.len + contents_slice.len + slice_sizes.len

This bug was found thanks to the gpa allocator which checks if freed
size matches allocated sizes for large allocations.

```

## Parents

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

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