Skip to content

Don't store null terminator in string buffer#17

Open
edsrzf wants to merge 1 commit into
krakjoe:developfrom
edsrzf:no-null-terminator
Open

Don't store null terminator in string buffer#17
edsrzf wants to merge 1 commit into
krakjoe:developfrom
edsrzf:no-null-terminator

Conversation

@edsrzf

@edsrzf edsrzf commented Jul 28, 2021

Copy link
Copy Markdown

We were not accounting for the null terminator in the string allocation, meaning that every string copy overflowed its buffer by one byte.

Usually the null terminator ended up getting overwritten by the first character of the next string copied into the buffer, but occasionally, due to concurrency, the null terminator from the first string could overwrite the first character of the second.

Since the null terminator is not actually necessary, this commit removes it from the string buffer. Now the allocation size is correct.

Fixes #16 using the first solution suggested in that issue. Read that issue for further details. The alternative would be to increase each string allocation size by 1.

We were not accounting for the null terminator in the string allocation,
meaning that every string copy overflowed its buffer by one byte.

Usually the null terminator ended up getting overwritten by the first
character of the next string copied into the buffer, but occasionally,
due to concurrency, the null terminator from the first string could
overwrite the first character of the second.

Since the null terminator is not actually necessary, this commit removes
it from the string buffer. Now the allocation size is correct.
mreishus added a commit to mreishus/tombs that referenced this pull request May 7, 2024
From: krakjoe#17
---

We were not accounting for the null terminator in the string allocation, meaning that every string copy overflowed its buffer by one byte.

Usually the null terminator ended up getting overwritten by the first character of the next string copied into the buffer, but occasionally, due to concurrency, the null terminator from the first string could overwrite the first character of the second.

Since the null terminator is not actually necessary, this commit removes it from the string buffer. Now the allocation size is correct.

Fixes #16 using the first solution suggested in that issue. Read that issue for further details. The alternative would be to increase each string allocation size by 1.

---
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Strings in dumped tombs sometimes start with null character

1 participant