GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — sqlite: check null returns from sqlite value functions · nodejs/node@b8faee0

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • src
    • node_sqlite.cc
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎src/node_sqlite.cc‎

Copy file name to clipboardExpand all lines: src/node_sqlite.cc
+7-1Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,10 @@ inline MaybeLocal<String> Utf8StringMaybeOneByte(Isolate* isolate,
121121
case SQLITE_TEXT: { \
122122
const char* v = \
123123
reinterpret_cast<const char*>(sqlite3_##from##_text(__VA_ARGS__)); \
124+
if (v == nullptr) [[unlikely]] { \
125+
THROW_ERR_MEMORY_ALLOCATION_FAILED((isolate)); \
126+
break; \
127+
} \
124128
const int v_len = sqlite3_##from##_bytes(__VA_ARGS__); \
125129
(result) = \
126130
Utf8StringMaybeOneByte((isolate), std::string_view(v, v_len)) \
@@ -138,7 +142,9 @@ inline MaybeLocal<String> Utf8StringMaybeOneByte(Isolate* isolate,
138142
sqlite3_##from##_blob(__VA_ARGS__)); \
139143
auto store = ArrayBuffer::NewBackingStore( \
140144
(isolate), size, BackingStoreInitializationMode::kUninitialized); \
141-
memcpy(store->Data(), data, size); \
145+
if (data != nullptr) [[likely]] { \
146+
memcpy(store->Data(), data, size); \
147+
} \
142148
auto ab = ArrayBuffer::New((isolate), std::move(store)); \
143149
(result) = Uint8Array::New(ab, 0, size); \
144150
break; \

0 commit comments

Comments
0 (0)
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.