buffer: revert GetBackingStore optimization in API
In an earlier PR, I replaced a lot of instances of GetBackingStore()->Data()
with Data()
. Apparently these two are not equivalent in the case of zero-length buffers: the former returns a "valid" address, while the latter returns NULL
. At least one library in the ecosystem (see the referenced issue) abuses zero-length buffers to wrap arbitrary pointers, which is broken by this difference. It is unfortunate that every library needs to take a performance hit because of this edge-case, and somebody should figure out if this is actually a reasonable contract to uphold long-term.
I have not traced down exactly why this divergence occurs, but I have verified that reverting this line fixes the referenced issue.
Refs: https://github.com/nodejs/node/pull/44080 Fixes: https://github.com/nodejs/node/issues/44554