Skip to content

Commit 6178b2c

Browse files
authored
throw ALLOCATION_FAILED exception. memcpy UB prevent
1 parent bad94ff commit 6178b2c

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

src/node_sqlite.cc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ using v8::Value;
9898
const char* v = \
9999
reinterpret_cast<const char*>(sqlite3_##from##_text(__VA_ARGS__)); \
100100
if (v == nullptr) { \
101-
(result) = Null((isolate)); \
101+
THROW_ERR_MEMORY_ALLOCATION_FAILED(isolate); \
102102
} else { \
103103
(result) = String::NewFromUtf8((isolate), v).As<Value>(); \
104104
} \
@@ -115,7 +115,9 @@ using v8::Value;
115115
sqlite3_##from##_blob(__VA_ARGS__)); \
116116
auto store = ArrayBuffer::NewBackingStore( \
117117
(isolate), size, BackingStoreInitializationMode::kUninitialized); \
118-
memcpy(store->Data(), data, size); \
118+
if (data) { \
119+
memcpy(store->Data(), data, size); \
120+
} \
119121
auto ab = ArrayBuffer::New((isolate), std::move(store)); \
120122
(result) = Uint8Array::New(ab, 0, size); \
121123
break; \

0 commit comments

Comments
 (0)