From f0d332e287d4807b5bfe757cdb5d7024c7fff69e Mon Sep 17 00:00:00 2001 From: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> Date: Thu, 4 Aug 2022 22:15:20 -0700 Subject: [bun:sqlite] Fix crash when > 64 columns Fixes https://github.com/oven-sh/bun/issues/987 --- src/bun.js/bindings/sqlite/JSSQLStatement.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/bun.js/bindings/sqlite/JSSQLStatement.cpp') 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); -- cgit v1.2.3