Skip to content
This repository has been archived by the owner on Jan 6, 2023. It is now read-only.

Reallocation does not set new memory area to zero #7

Open
wusto opened this issue May 30, 2022 · 0 comments
Open

Reallocation does not set new memory area to zero #7

wusto opened this issue May 30, 2022 · 0 comments

Comments

@wusto
Copy link

wusto commented May 30, 2022

From realloc man page:
"If the new size is larger than the old size, the added memory will not be initialized."

data = realloc(data, sizeof(struct line_data)*line_data_buf);

As the first call is to calloc, this might lead to false assumptions when accessing the memory.

A possible solution is to memset the data buffer after realloc.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant