Skip to content
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

Corner case: will not match NULL #49

Open
kuldeepdhaka opened this issue Feb 28, 2016 · 4 comments
Open

Corner case: will not match NULL #49

kuldeepdhaka opened this issue Feb 28, 2016 · 4 comments

Comments

@kuldeepdhaka
Copy link

https://github.com/TooTallNate/ref/blob/master/src/binding.cc#L514

  int64_t offset = GetInt64(info[2]);
  char *ptr = Buffer::Data(buf.As<Object>()) + offset;

  if (ptr == NULL) {
    return Nan::ThrowError("reinterpret: Cannot reinterpret from NULL pointer");
  }

if offset > 0 then checking ptr == NULL will not match even if Buffer::Data(buf.As<Object>()) return NULL

etiher checking is useless or we need to check for NULL before adding offset.

@TooTallNate
Copy link
Owner

Ya good point we should deprecate the parameter with a warning and then remove it in the next major version.

@TooTallNate
Copy link
Owner

PR welcome.

@kuldeepdhaka
Copy link
Author

probebly removing offset is a good idea.
also, offset can be applied using Buffer.slice (which uses TypedArray subarray())

@kuldeepdhaka
Copy link
Author

BUT adding offset and NULL checking style is used through out the c++ code.
better is to remove from everywhere. (present in ReadObject, ReadPointer, ReadInt64, ReadUInt64, ReadCString also)
This would require considerable api change

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants