Skip to content

Commit bad94ff

Browse files
committed
fix: address static analysis warnings in SQLite and WebStorage
1 parent e1fc3dc commit bad94ff

2 files changed

Lines changed: 7 additions & 2 deletions

File tree

src/node_sqlite.cc

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,11 @@ using v8::Value;
9797
case SQLITE_TEXT: { \
9898
const char* v = \
9999
reinterpret_cast<const char*>(sqlite3_##from##_text(__VA_ARGS__)); \
100-
(result) = String::NewFromUtf8((isolate), v).As<Value>(); \
100+
if (v == nullptr) { \
101+
(result) = Null((isolate)); \
102+
} else { \
103+
(result) = String::NewFromUtf8((isolate), v).As<Value>(); \
104+
} \
101105
break; \
102106
} \
103107
case SQLITE_NULL: { \
@@ -246,7 +250,7 @@ inline void THROW_ERR_SQLITE_ERROR(Isolate* isolate, int errcode) {
246250

247251
Environment* env = Environment::GetCurrent(isolate);
248252
Local<Object> error;
249-
if (CreateSQLiteError(isolate, errstr).ToLocal(&error) &&
253+
if (env && CreateSQLiteError(isolate, errstr).ToLocal(&error) &&
250254
error
251255
->Set(isolate->GetCurrentContext(),
252256
env->errcode_string(),

src/node_webstorage.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,7 @@ Maybe<void> Storage::Open() {
177177
sqlite3_stmt* s = nullptr;
178178
r = sqlite3_prepare_v2(
179179
db, get_schema_version_sql.data(), get_schema_version_sql.size(), &s, 0);
180+
CHECK_ERROR_OR_THROW(env(), r, SQLITE_OK, Nothing<void>());
180181
r = sqlite3_exec(db, init_sql_v0.data(), 0, 0, nullptr);
181182
CHECK_ERROR_OR_THROW(env(), r, SQLITE_OK, Nothing<void>());
182183
auto stmt = stmt_unique_ptr(s);

0 commit comments

Comments
 (0)