-
Notifications
You must be signed in to change notification settings - Fork 31k
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
Buffer doesn't throw error for invalid parameter type #210
Comments
I believe the motivation was to make it more aligned with the implicit type coercion that you get in most places; e.g. typed arrays: @trevnorris I believe you were responsible for that change? Can you comment? |
* `NanCallback` throws errors to global, instead of current scope. So it can't be caught by `TryCatch` within `CallbackInfo::DispatchToV8`. * `Buffer` in node.js 0.11 failed to detecting invalid parameters as 0.10 did nodejs/node#210
Exactly what @bnoordhuis said. |
In other word, this is a fix rather than a bug, right? |
Closing this as "working as intended." If I'm incorrect, please let me know and I can reopen. |
- Check that an internal field value is actually an External before casting. This prevents a crash if the wrong object is passed to napi_unwrap. - Wrap some macro parameters in parentheses.
- Check that an internal field value is actually an External before casting. This prevents a crash if the wrong object is passed to napi_unwrap. - Wrap some macro parameters in parentheses.
In Node.js 0.10, invalid parameter type
String
will cause some Buffer APIs, likewriteUint32LE('some string', 0)
, throwing an "value is out of bounds" error. The parameter is checked bycheckInt
function:However in Node.js / io.js 0.11 & 0.12, the check function is changed into following, which doesn't throw any errors for invalid values:
This is an inconsistent behavior, which should be fixed.
The text was updated successfully, but these errors were encountered: