Skip to content

Commit bac3a48

Browse files
tniessentargos
authored andcommitted
src: fix potential segmentation fault in SQLite
The Local<Value> returned from ColumnToValue() and ColumnNameToValue() may be empty (if a JavaScript exception is pending), in which case a segmentation fault may occur at the call sites, which do not check if the Local<Value> is empty. Fix this bug returning early if an exception is pending (as indicated by the Local being empty). In the long term, these functions should return MaybeLocal instead of Local, but this patch is supposed to be a minimal bug fix only. PR-URL: #53850 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Yagiz Nizipli <[email protected]>
1 parent 97da7ca commit bac3a48

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/node_sqlite.cc

+4
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,9 @@ void StatementSync::All(const FunctionCallbackInfo<Value>& args) {
441441

442442
for (int i = 0; i < num_cols; ++i) {
443443
Local<Value> key = stmt->ColumnNameToValue(i);
444+
if (key.IsEmpty()) return;
444445
Local<Value> val = stmt->ColumnToValue(i);
446+
if (val.IsEmpty()) return;
445447

446448
if (row->Set(env->context(), key, val).IsNothing()) {
447449
return;
@@ -483,7 +485,9 @@ void StatementSync::Get(const FunctionCallbackInfo<Value>& args) {
483485

484486
for (int i = 0; i < num_cols; ++i) {
485487
Local<Value> key = stmt->ColumnNameToValue(i);
488+
if (key.IsEmpty()) return;
486489
Local<Value> val = stmt->ColumnToValue(i);
490+
if (val.IsEmpty()) return;
487491

488492
if (result->Set(env->context(), key, val).IsNothing()) {
489493
return;

0 commit comments

Comments
 (0)