-
Notifications
You must be signed in to change notification settings - Fork 82
Make encodeInto() throw when given a detached buffer #324
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
Comments
cc @ricea |
Chrome accidentally does nothing successfully. I think we should throw. My guess is that no-one is intentionally using the current behaviour. |
Is the goal to add a one-off check to Encoding, or to throw at the Web IDL layer? The latter would be kind of nice, but perhaps scarier. |
Throwing at the IDL layer would change the exception for everything calling into StructuredSerializeWithTransfer at least. Not sure that's really possible. My idea was to add one-off checks and also to assert that the buffer is not detached in various IDL algorithms so callers are "forced" to deal with it. |
This also applies to I suspect it's all aligned with the original non-throwy view APIs. This makes me a bit more worried about introducing a throw here and there as it seems unlikely we will be able to be consistent. Thoughts? |
I was made aware of this issue while fixing a crash in ladybird that was caused by passing a detached buffer to In my opinion, throwing would have been the better solution, but this noop behavior is already widely adapted. Thus it would make sense to also explicitly include it in the spec. |
In whatwg/webidl#1385 we discovered some specification UB. However, that also raised the question as to whether this method should perhaps be throwing an exception when given a detached buffer.
I tend to think it should and hopefully there's no callers relying on it not throwing as it's still early days?
cc @hsivonen @inexorabletash @youennf
The text was updated successfully, but these errors were encountered: