From fe0bf6b7ac2063030924e0734d90b600e2c811cb Mon Sep 17 00:00:00 2001 From: Trevor Norris Date: Fri, 11 Oct 2013 11:11:36 -0700 Subject: [PATCH] buffer: check data is not null Because it's possible for the data within a Buffer instance to be altered after instantiation, or in case a user attempts to do something like the following: Buffer.prototype.fill.call({}, 10, 0, 10); It doesn't result in a segfault. --- src/node_buffer.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/node_buffer.cc b/src/node_buffer.cc index 2e7374971c..61980cb095 100644 --- a/src/node_buffer.cc +++ b/src/node_buffer.cc @@ -43,7 +43,9 @@ Local obj = argT; \ size_t obj_length = obj->GetIndexedPropertiesExternalArrayDataLength(); \ char* obj_data = static_cast( \ - obj->GetIndexedPropertiesExternalArrayData()); + obj->GetIndexedPropertiesExternalArrayData()); \ + if (obj_length > 0) \ + assert(obj_data != NULL); #define SLICE_START_END(start_arg, end_arg, end_max) \ size_t start; \