1111 stackSave
1212 UTF8ToString
1313 stringToNewUTF8
14- allocateUTF8OnStack
1514 removeFunction
1615 addFunction
1716 writeArrayToMemory
@@ -947,25 +946,27 @@ Module["onRuntimeInitialized"] = function onRuntimeInitialized() {
947946 if ( ! this . db ) {
948947 throw "Database closed" ;
949948 }
950- var stack = stackSave ( ) ;
951949 var stmt = null ;
950+ var originalSqlPtr = null ;
951+ var currentSqlPtr = null ;
952952 try {
953- var nextSqlPtr = allocateUTF8OnStack ( sql ) ;
953+ originalSqlPtr = stringToNewUTF8 ( sql ) ;
954+ currentSqlPtr = originalSqlPtr ;
954955 var pzTail = stackAlloc ( 4 ) ;
955956 var results = [ ] ;
956- while ( getValue ( nextSqlPtr , "i8" ) !== NULL ) {
957+ while ( getValue ( currentSqlPtr , "i8" ) !== NULL ) {
957958 setValue ( apiTemp , 0 , "i32" ) ;
958959 setValue ( pzTail , 0 , "i32" ) ;
959960 this . handleError ( sqlite3_prepare_v2_sqlptr (
960961 this . db ,
961- nextSqlPtr ,
962+ currentSqlPtr ,
962963 - 1 ,
963964 apiTemp ,
964965 pzTail
965966 ) ) ;
966967 // pointer to a statement, or null
967968 var pStmt = getValue ( apiTemp , "i32" ) ;
968- nextSqlPtr = getValue ( pzTail , "i32" ) ;
969+ currentSqlPtr = getValue ( pzTail , "i32" ) ;
969970 // Empty statement
970971 if ( pStmt !== NULL ) {
971972 var curresult = null ;
@@ -991,7 +992,7 @@ Module["onRuntimeInitialized"] = function onRuntimeInitialized() {
991992 if ( stmt ) stmt [ "free" ] ( ) ;
992993 throw errCaught ;
993994 } finally {
994- stackRestore ( stack ) ;
995+ if ( originalSqlPtr ) _free ( originalSqlPtr ) ;
995996 }
996997 } ;
997998
0 commit comments