mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 10:59:27 +00:00
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: https://github.com/nodejs/node/pull/53850 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
This commit is contained in:
parent
f09063752b
commit
0b1ff6965e
@ -441,7 +441,9 @@ void StatementSync::All(const FunctionCallbackInfo<Value>& args) {
|
||||
|
||||
for (int i = 0; i < num_cols; ++i) {
|
||||
Local<Value> key = stmt->ColumnNameToValue(i);
|
||||
if (key.IsEmpty()) return;
|
||||
Local<Value> val = stmt->ColumnToValue(i);
|
||||
if (val.IsEmpty()) return;
|
||||
|
||||
if (row->Set(env->context(), key, val).IsNothing()) {
|
||||
return;
|
||||
@ -483,7 +485,9 @@ void StatementSync::Get(const FunctionCallbackInfo<Value>& args) {
|
||||
|
||||
for (int i = 0; i < num_cols; ++i) {
|
||||
Local<Value> key = stmt->ColumnNameToValue(i);
|
||||
if (key.IsEmpty()) return;
|
||||
Local<Value> val = stmt->ColumnToValue(i);
|
||||
if (val.IsEmpty()) return;
|
||||
|
||||
if (result->Set(env->context(), key, val).IsNothing()) {
|
||||
return;
|
||||
|
Loading…
Reference in New Issue
Block a user