Skip to content

Conversation

@febo
Copy link
Collaborator

@febo febo commented Jul 17, 2025

Problem

The current behaviour of AccountInfo::realloc allowing to skip zero-initializing the memory is deprecated. Programs should not rely that newly-allocated memory is zeroed. A new resize method was introduced to zero-initialize the data, although programs might define alternative initialization that do not require the data to be zeroed.

Solution

This PR modifies the realloc implementation to use resize, thus ignoring the zero_init parameter and always zero-initializing the data. Additionally, it adds a resize_unchecked, which can be used when the program performs the account data borrow check and initialization of the allocated memory.

@febo
Copy link
Collaborator Author

febo commented Jul 17, 2025

This will be refactored to provide a MaybeUninit<&[u8]> return.

@febo febo closed this Jul 17, 2025
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.

2 participants