Skip to content

Commit

Permalink
* Add isolate to bson.cc and win_delay_load_hook
Browse files Browse the repository at this point in the history
  Contributed by: @Demiguise
  • Loading branch information
audreyt committed Jul 25, 2016
1 parent 19355a6 commit 929b26c
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 14 deletions.
36 changes: 25 additions & 11 deletions binding.gyp
Original file line number Diff line number Diff line change
@@ -1,17 +1,31 @@
{
'targets': [
"targets": [
{
'target_name': 'WebWorkerThreads',
'sources': [ 'src/WebWorkerThreads.cc' ],
'cflags!': [ '-fno-exceptions', '-DV8_USE_UNSAFE_HANDLES' ],
'cflags_cc!': [ '-fno-exceptions', '-DV8_USE_UNSAFE_HANDLES' ],
'include_dirs': [ '<!(node -e "require(\'nan\')")' ],
'conditions': [
['OS=="mac"', {
'xcode_settings': {
'GCC_ENABLE_CPP_EXCEPTIONS': 'YES'
"target_name": "WebWorkerThreads",
"sources": [
"src/WebWorkerThreads.cc"
],
"cflags!": [
"-fno-exceptions",
"-DV8_USE_UNSAFE_HANDLES"
],
"cflags_cc!": [
"-fno-exceptions",
"-DV8_USE_UNSAFE_HANDLES"
],
"include_dirs": [
"<!(node -e \"require('nan')\")"
],
"win_delay_load_hook": "<!(node -e \"var v = process.version.substring(1,2); console.log(v > 0 && v < 4);\")",
"conditions": [
[
"OS==\"mac\"",
{
"xcode_settings": {
"GCC_ENABLE_CPP_EXCEPTIONS": "YES"
}
}
}]
]
]
}
]
Expand Down
8 changes: 5 additions & 3 deletions src/bson.cc
Original file line number Diff line number Diff line change
Expand Up @@ -792,15 +792,16 @@ NAN_METHOD(BSON::BSONDeserialize)
}
else
{
Isolate* isolate = Isolate::GetCurrent();
// The length of the data for this encoding
intptr_t len = DecodeBytes(info[0], BINARY);
intptr_t len = DecodeBytes(isolate, info[0], BINARY);

// Validate that we have at least 5 bytes
if(len < 5) return Nan::ThrowError("corrupt bson message < 5 bytes long");

// Let's define the buffer size
char* data = (char *)malloc(len);
DecodeWrite(data, len, info[0], BINARY);
DecodeWrite(isolate, data, len, info[0], BINARY);

try
{
Expand Down Expand Up @@ -894,7 +895,8 @@ NAN_METHOD(BSON::BSONSerialize)
}
else
{
Local<Value> bin_value = Encode(serialized_object, object_size, BINARY)->ToString();
Isolate* isolate = Isolate::GetCurrent();
Local<Value> bin_value = Encode(isolate, serialized_object, object_size, BINARY)->ToString();
free(serialized_object);
info.GetReturnValue().Set(bin_value);
}
Expand Down

0 comments on commit 929b26c

Please sign in to comment.