-
-
Notifications
You must be signed in to change notification settings - Fork 107
dc_array: panic on null pointers and out of range indexes #333
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
(*array).get_ptr(index) | ||
} | ||
assert!(!array.is_null()); | ||
(*array).get_ptr(index) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here you remove index >= (*array).len()
check.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
get_ptr()
does this check. It is safe, actually.
WIP as I want to rebase it on top of #334 |
} else { | ||
(*array).get_uint(index) | ||
} | ||
assert!(!array.is_null()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Panicing on a null pointer changes the behaviour of the ffi, i think we should avoid this. If it's null, we should return a 0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@r10s what do you think about this? Is it likely that we break android/ios at some points with this change?
<Jikstra> we have to be careful with panics in the ffi just because array is a null pointer
<Jikstra> the api allowed us to do weird stuff, panicing will break all apps based on -core-rust
<link2xt[m]> yes, but such panics can be easily debugged
<link2xt[m]> if FFI call panics, it panics immediately
<link2xt[m]> and then you know you should not pass invalid value into it
<link2xt[m]> a simple if is enough to fix it in this case, but it may happen to be an actual bug
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now going to move all unsafe code to FFI |
No description provided.