Skip to content
This repository has been archived by the owner on Aug 20, 2021. It is now read-only.

(Not)Equivalent of dangling pointer dereferencing when calling path after into_path #20

Closed
lilianmoraru opened this issue Mar 5, 2017 · 2 comments

Comments

@lilianmoraru
Copy link

I was just looking through the code("looking for inspiration") and observed a bug that is the equivalent of dangling pointers but with Rust Options(of course, no memory corruption).
When calling into_path, path will be replaced with None - then -> if somebody calls the path function, the application will panic(because it unwraps for the user - which would be the equivalent of dereferencing a dangling pointer).
I think it's better to break the API(v0.4) and make this function return an Option<&path::Path>, or maybe some other option(solution).

@lilianmoraru
Copy link
Author

My mistake.
Because into_path takes mut self and not &mut self, TempDir is released and there is no risk of using this resource later - very nice.
I will use the same technique - seems like I did get "inspired" in the end 😄

@lilianmoraru lilianmoraru changed the title Equivalent of dangling pointer dereferencing when calling path after into_path (Not)Equivalent of dangling pointer dereferencing when calling path after into_path Mar 5, 2017
@lilianmoraru
Copy link
Author

Well, I reviewed more of the code this time and observed some issues.

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