]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
In wasm.ptr.coerce(), treat the undefined value the same as 0 for Number-type pointer...
authorstephan <stephan@noemail.net>
Mon, 22 Sep 2025 13:13:02 +0000 (13:13 +0000)
committerstephan <stephan@noemail.net>
Mon, 22 Sep 2025 13:13:02 +0000 (13:13 +0000)
FossilOrigin-Name: ef73bb1ddae28c6a0b462a2a840bfaaec3fc70d843e9ab6c53097281ffc85a78

ext/wasm/common/whwasmutil.js
manifest
manifest.uuid

index 1f732eb1c1e3e65c6fecf6d45de2294e994dfcd3..1c678f31f6899ecf99b9a7a1d87799a4b1aadeca 100644 (file)
@@ -252,14 +252,19 @@ globalThis.WhWasmUtilInstaller = function(target){
         ? (v)=>BigInt(v || 0)
         : (v)=>toss("BigInt support is disabled in this build.");
 
+  const __Number = (v)=>Number(v||0)/*treat undefined the same as null*/;
+
   /**
      If target.ptr.ir==='i32' then this is equivalent to
-     Number(v) else it's equivalent to BigInt(v||0), throwing
+     Number(v||0) else it's equivalent to BigInt(v||0), throwing
      if BigInt support is disabled.
 
-     Why? Because Number(null)===0, but BigInt(null) throws.
+     Why? Because Number(null)===0, but BigInt(null) throws.  We
+     perform the same for Number to allow the undefined value to be
+     treated as a NULL WASM pointer, primarily to reduce friction in
+     many SQLite3 bindings which have long relied on that.
   */
-  const __asPtrType = (4===__ptrSize) ? Number : __BigInt;
+  const __asPtrType = (4===__ptrSize) ? __Number : __BigInt;
 
   /**
      The number 0 as either type Number or BigInt, depending on
index 2091765cf2bfc936b766b7d2991f75b90dbd01b1..53932ecf2ed6c7bb3cc74043c399e4ddd3c516b3 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Minor\sdoc\supdates.\sNo\sfunctional\schanges.
-D 2025-09-22T11:52:06.578
+C In\swasm.ptr.coerce(),\streat\sthe\sundefined\svalue\sthe\ssame\sas\s0\sfor\sNumber-type\spointers\sfor\sconsistency\swith\sthe\sBigInt\scoercion.\sThe\sbindings\shave\slong\streated\sboth\snull\sand\sundefined\sas\s===\s0\sfor\spointer\soperations.
+D 2025-09-22T13:13:02.792
 F .fossil-settings/binary-glob 61195414528fb3ea9693577e1980230d78a1f8b0a54c78cf1b9b24d0a409ed6a x
 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
@@ -618,7 +618,7 @@ F ext/wasm/c-pp.c cca55c5b55ebd8d29916adbedb0e40baa12caa9a2e8429f812683c308f9b0e
 F ext/wasm/common/SqliteTestUtil.js 7adaeffef757d8708418dc9190f72df22367b531831775804b31598b44f6aa51
 F ext/wasm/common/emscripten.css 11bd104b6c0d597c67d40cc8ecc0a60dae2b965151e3b6a37fa5708bac3acd15
 F ext/wasm/common/testing.css e97549bab24126c24e0daabfe2de9bb478fb0a69fdb2ddd0a73a992c091aad6f
-F ext/wasm/common/whwasmutil.js a4d0736b7e3abfbbe5342743d11c4663a9a1411def3a25cf6a3f5982baa73f95
+F ext/wasm/common/whwasmutil.js 0d539324097fc83b953e9844267359ba0fd02286caa784ea2f597ced279ea640
 F ext/wasm/config.make.in c424ae1cc3c89274520ad312509d36c4daa34a3fce5d0c688e5f8f4365e1049a
 F ext/wasm/demo-123-worker.html a0b58d9caef098a626a1a1db567076fca4245e8d60ba94557ede8684350a81ed
 F ext/wasm/demo-123.html 8c70a412ce386bd3796534257935eb1e3ea5c581e5d5aea0490b8232e570a508
@@ -2175,8 +2175,8 @@ F tool/version-info.c 3b36468a90faf1bbd59c65fd0eb66522d9f941eedd364fabccd7227350
 F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee87c1b31a7
 F tool/warnings.sh 1ad0169b022b280bcaaf94a7fa231591be96b514230ab5c98fbf15cd7df842dd
 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
-P 8ac367686fecd2e3ff1f4b4565e9f206a64237744e381704693df2e6efbe235a
-R c7473722f649ce741b998c43467cc34d
+P 9c67299b452a2b19b5f4285feb975b30864a9415ccf62b7c7ebb1587a6545b33
+R 59f0a48db226fe4ded8a844d226299c9
 U stephan
-Z 724707217daa9a8f6c1d855a49d7a1d7
+Z ed7b40cd76490118310a2fe0366a4ee8
 # Remove this line to create a well-formed Fossil manifest.
index a21c50769f1825fbd07120b29cd92d74eade666e..644de25ff285b24b9b99cbc92d2fcb367228600c 100644 (file)
@@ -1 +1 @@
-9c67299b452a2b19b5f4285feb975b30864a9415ccf62b7c7ebb1587a6545b33
+ef73bb1ddae28c6a0b462a2a840bfaaec3fc70d843e9ab6c53097281ffc85a78