Skip to content

Commit fe0bf6b

Browse files
committed
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.
1 parent 66b8c3c commit fe0bf6b

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

src/node_buffer.cc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,9 @@
4343
Local<Object> obj = argT; \
4444
size_t obj_length = obj->GetIndexedPropertiesExternalArrayDataLength(); \
4545
char* obj_data = static_cast<char*>( \
46-
obj->GetIndexedPropertiesExternalArrayData());
46+
obj->GetIndexedPropertiesExternalArrayData()); \
47+
if (obj_length > 0) \
48+
assert(obj_data != NULL);
4749

4850
#define SLICE_START_END(start_arg, end_arg, end_max) \
4951
size_t start; \

0 commit comments

Comments
 (0)