Skip to content

Fixed unwind safe within zip_elements#2

Open
Phosphorus15 wants to merge 4 commits into
strake:masterfrom
Phosphorus15:master
Open

Fixed unwind safe within zip_elements#2
Phosphorus15 wants to merge 4 commits into
strake:masterfrom
Phosphorus15:master

Conversation

@Phosphorus15

Copy link
Copy Markdown

This should fixes #1 , which wraps a ManuallyDrop around the original matrix to prevent unintentional dropping of its elements.

@Phosphorus15 Phosphorus15 changed the title Fixed unwind safe within map_elements Fixed unwind safe within zip_elements Sep 13, 2019
@strake

strake commented Sep 24, 2019

Copy link
Copy Markdown
Owner

The PR title says "zip_elements" but it seems you are modifying map_elements. I assume zip_elements is also broken, yes?

Comment thread src/lib.rs Outdated
#[inline] fn map_elements<B, F: FnMut(A) -> B>(self, mut f: F) -> Matrix<B, M, N>
where M: ArrayLength<B>, N: ArrayLength<GenericArray<B, M>> {
let Matrix(a) = self;
let _wrapper = mem::ManuallyDrop::new(a);

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the leading underscore? We use it below.

Comment thread src/lib.rs Outdated
mem::forget(a);
Matrix(c)
}

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Scrub this, please

@Phosphorus15

Copy link
Copy Markdown
Author

The PR title says "zip_elements" but it seems you are modifying map_elements. I assume zip_elements is also broken, yes?

Yeah, that's my fault, I'll fix this soon.

@Phosphorus15

Copy link
Copy Markdown
Author

The PR title says "zip_elements" but it seems you are modifying map_elements. I assume zip_elements is also broken, yes?

Yeah, that's my fault, I'll fix this soon.

By this I mean, they are both broken. 😂

@Phosphorus15

Phosphorus15 commented Sep 24, 2019

Copy link
Copy Markdown
Author

The code reformatter might have changed the codes format .. hope you don't mind 😭

@strake

strake commented Sep 24, 2019

Copy link
Copy Markdown
Owner

I'd prefer you not reformat the file...

@Phosphorus15

Copy link
Copy Markdown
Author

This should make it sound

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.

Method zip_elements suffers from double free vulnerability

2 participants