Skip to content

Commit

Permalink
Fixed an offset error in Node buffer handling (#4826)
Browse files Browse the repository at this point in the history
  • Loading branch information
FFranck authored Aug 31, 2022
1 parent 47d45c8 commit a276796
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ NOTE: This version is unrelated to the v10.20.0-alpha and v10.20.0-beta prerelea
* Fixed an incorrect git merge in the Xcode project from RN iOS. ([#4756](https://github.com/realm/realm-js/issues/4756), since v10.19.5)
* Fixed detection of emulator environments to be more robust. Thanks to [Ferry Kranenburg](https://github.com/fkranenburg) for identifying the issue and supplying a PR. ([#4784](https://github.com/realm/realm-js/issues/4784))
* Opening a read-only synced Realm for the first time could lead to `m_schema_version != ObjectStore::NotVersioned` assertion.
* Fixed an offset error in Node buffer handling ([#3781](https://github.com/realm/realm-js/issues/3781), since v10.0.0)

### Compatibility
* React Native >= v0.64.0
Expand Down
8 changes: 4 additions & 4 deletions src/node/node_buffer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,15 @@ auto get_data(ArrayBuffer buffer)
template <>
auto get_data<DataView>(DataView data_view)
{
auto buffer = data_view.ArrayBuffer();
return static_cast<const char*>(buffer.Data());
Napi::ArrayBuffer buffer = data_view.ArrayBuffer();
return (static_cast<const char*>(buffer.Data()) + data_view.ByteOffset());
}

template <>
auto get_data<TypedArray>(TypedArray typed_array)
{
auto buffer = typed_array.ArrayBuffer();
return static_cast<const char*>(buffer.Data());
Napi::ArrayBuffer buffer = typed_array.ArrayBuffer();
return (static_cast<const char*>(buffer.Data())) + typed_array.ByteOffset();
}

class NodeBinary {
Expand Down

0 comments on commit a276796

Please sign in to comment.