@@ -107,6 +107,7 @@ public struct BridgeJSLink {
107107 /// Represents a Swift heap object like a class instance or an actor instance.
108108 class SwiftHeapObject {
109109 static __wrap(pointer, deinit, prototype, identityCache) {
110+ pointer = pointer >>> 0;
110111 const makeFresh = (identityMap) => {
111112 const obj = Object.create(prototype);
112113 const state = { pointer, deinit, hasReleased: false, identityMap };
@@ -428,7 +429,7 @@ public struct BridgeJSLink {
428429 " \( JSGlueVariableScope . reservedSwift) . \( JSGlueVariableScope . reservedMemory) .release(sourceId); "
429430 )
430431 printer. write (
431- " const bytes = new Uint8Array( \( JSGlueVariableScope . reservedMemory) .buffer, bytesPtr); "
432+ " const bytes = new Uint8Array( \( JSGlueVariableScope . reservedMemory) .buffer, bytesPtr >>> 0 ); "
432433 )
433434 printer. write ( " bytes.set(source); " )
434435 }
@@ -443,7 +444,7 @@ public struct BridgeJSLink {
443444 printer. write ( " bjs[ \" swift_js_init_memory_with_result \" ] = function(ptr, len) { " )
444445 printer. indent {
445446 printer. write (
446- " const target = new Uint8Array( \( JSGlueVariableScope . reservedMemory) .buffer, ptr, len); "
447+ " const target = new Uint8Array( \( JSGlueVariableScope . reservedMemory) .buffer, ptr >>> 0 , len >>> 0 ); "
447448 )
448449 printer. write ( " target.set( \( JSGlueVariableScope . reservedStorageToReturnBytes) ); " )
449450 printer. write ( " \( JSGlueVariableScope . reservedStorageToReturnBytes) = undefined; " )
@@ -789,7 +790,7 @@ public struct BridgeJSLink {
789790 helperPrinter. write ( " if (state.unregistered) { " )
790791 helperPrinter. indent {
791792 helperPrinter. write (
792- " const bytes = new Uint8Array( \( JSGlueVariableScope . reservedMemory) .buffer, state.file); "
793+ " const bytes = new Uint8Array( \( JSGlueVariableScope . reservedMemory) .buffer, state.file >>> 0 ); "
793794 )
794795 helperPrinter. write ( " let length = 0; " )
795796 helperPrinter. write ( " while (bytes[length] !== 0) { length += 1; } " )
0 commit comments