Skip to content

Remove unnecessary fill(0) before drop#45

Open
asmodehn wants to merge 1 commit into
librespeed:masterfrom
asmodehn:cleanup_fill_0
Open

Remove unnecessary fill(0) before drop#45
asmodehn wants to merge 1 commit into
librespeed:masterfrom
asmodehn:cleanup_fill_0

Conversation

@asmodehn

Copy link
Copy Markdown

This is rust, it is perfectly safe to drop the memory directly, no point to fill(0) before:

All elements of arrays are always initialized, and access to an array is always bounds-checked in safe methods and operators.

Do not rely on removed data to be erased for security purposes. Even if you drop a Vec, its buffer may simply be reused by another allocation. Even if you zero a Vec’s memory first, that might not actually happen because the optimizer does not consider this a side-effect that must be preserved.

@SudoDios

Copy link
Copy Markdown
Collaborator

Hi @asmodehn
Thank you

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