neon-bindings / neon

Rust bindings for writing safe and fast native Node.js modules.
https://www.neon-bindings.com/
Apache License 2.0
7.98k stars 282 forks source link

fix(neon): Fix a panic when borrowing an empty buffer or typed array #1058

Closed kjvalencik closed 1 month ago

kjvalencik commented 1 month ago

The borrow API currently panics if trying to borrow an empty buffer. This is because the pointer will be nil.

This PR adds guards for length != 0. Additionally, the ledger skips adding/removing empty buffers.