diff options
author | 2022-08-04 22:15:20 -0700 | |
---|---|---|
committer | 2022-08-04 22:16:05 -0700 | |
commit | f0d332e287d4807b5bfe757cdb5d7024c7fff69e (patch) | |
tree | cd54cd9be1403fc3445038d663cdc33af90ce056 /src/bun.js/bindings/sqlite/JSSQLStatement.cpp | |
parent | e7ecedf3e9ec008b1f0ac55f1c947ccde454fbe8 (diff) | |
download | bun-f0d332e287d4807b5bfe757cdb5d7024c7fff69e.tar.gz bun-f0d332e287d4807b5bfe757cdb5d7024c7fff69e.tar.zst bun-f0d332e287d4807b5bfe757cdb5d7024c7fff69e.zip |
[bun:sqlite] Fix crash when > 64 columns
Fixes https://github.com/oven-sh/bun/issues/987
Diffstat (limited to 'src/bun.js/bindings/sqlite/JSSQLStatement.cpp')
-rw-r--r-- | src/bun.js/bindings/sqlite/JSSQLStatement.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/bun.js/bindings/sqlite/JSSQLStatement.cpp b/src/bun.js/bindings/sqlite/JSSQLStatement.cpp index 7f740ae66..7f90360f6 100644 --- a/src/bun.js/bindings/sqlite/JSSQLStatement.cpp +++ b/src/bun.js/bindings/sqlite/JSSQLStatement.cpp @@ -1000,7 +1000,10 @@ static void initializeColumnNames(JSC::JSGlobalObject* lexicalGlobalObject, JSSQ if (count == 0) return; JSC::ObjectInitializationScope initializationScope(vm); - JSC::JSObject* object = JSC::constructEmptyObject(lexicalGlobalObject, lexicalGlobalObject->objectPrototype(), count); + + // 64 is the maximum we can preallocate here + // see https://github.com/oven-sh/bun/issues/987 + JSC::JSObject* object = JSC::constructEmptyObject(lexicalGlobalObject, lexicalGlobalObject->objectPrototype(), std::min(count, 64)); for (int i = 0; i < count; i++) { const char* name = sqlite3_column_name(stmt, i); |