Commit 37cccc89 by Konstantin Käfer

copy buffer data so that we can safely call free on it later

parent 73f3fcae
...@@ -225,7 +225,9 @@ Handle<Value> Statement::BindObject(const Arguments& args) { ...@@ -225,7 +225,9 @@ Handle<Value> Statement::BindObject(const Arguments& args) {
else if (Buffer::HasInstance(val)) { else if (Buffer::HasInstance(val)) {
pairs->value_type = VALUE_BLOB; pairs->value_type = VALUE_BLOB;
Buffer* buffer = Buffer::Unwrap<Buffer>(val->ToObject()); Buffer* buffer = Buffer::Unwrap<Buffer>(val->ToObject());
pairs->value = buffer->data(); char *value = (char *) malloc(buffer->length());
memcpy(value, buffer->data(), buffer->length());
pairs->value = value;
pairs->value_size = buffer->length(); pairs->value_size = buffer->length();
} }
else if (val->IsNull() || val->IsUndefined()) { else if (val->IsNull() || val->IsUndefined()) {
...@@ -305,7 +307,9 @@ Handle<Value> Statement::BindArray(const Arguments& args) { ...@@ -305,7 +307,9 @@ Handle<Value> Statement::BindArray(const Arguments& args) {
else if (Buffer::HasInstance(val)) { else if (Buffer::HasInstance(val)) {
pairs->value_type = VALUE_BLOB; pairs->value_type = VALUE_BLOB;
Buffer* buffer = Buffer::Unwrap<Buffer>(val->ToObject()); Buffer* buffer = Buffer::Unwrap<Buffer>(val->ToObject());
pairs->value = buffer->data(); char *value = (char *) malloc(buffer->length());
memcpy(value, buffer->data(), buffer->length());
pairs->value = value;
pairs->value_size = buffer->length(); pairs->value_size = buffer->length();
} }
else if (val->IsNull() || val->IsUndefined()) { else if (val->IsNull() || val->IsUndefined()) {
...@@ -407,7 +411,9 @@ Handle<Value> Statement::Bind(const Arguments& args) { ...@@ -407,7 +411,9 @@ Handle<Value> Statement::Bind(const Arguments& args) {
else if (Buffer::HasInstance(args[1])) { else if (Buffer::HasInstance(args[1])) {
pair->value_type = VALUE_BLOB; pair->value_type = VALUE_BLOB;
Buffer* buffer = Buffer::Unwrap<Buffer>(args[1]->ToObject()); Buffer* buffer = Buffer::Unwrap<Buffer>(args[1]->ToObject());
pair->value = buffer->data(); char *value = (char *) malloc(buffer->length());
memcpy(value, buffer->data(), buffer->length());
pair->value = value;
pair->value_size = buffer->length(); pair->value_size = buffer->length();
} }
else if (args[1]->IsNull() || args[1]->IsUndefined()) { else if (args[1]->IsNull() || args[1]->IsUndefined()) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment