diff --git a/src/SDL.c b/src/SDL.c index 72c4d77b5f..13ef829bee 100644 --- a/src/SDL.c +++ b/src/SDL.c @@ -359,7 +359,7 @@ bool SDL_InitSubSystem(SDL_InitFlags flags) if (typeof(SDL3.CPtrToHeap32Index) === 'undefined') { SDL3.CPtrToHeap32Index = function(ptr) { return ptr >>> 2; }; } #elif defined(__wasm64__) if (typeof(SDL3.JSVarToCPtr) === 'undefined') { SDL3.JSVarToCPtr = function(v) { return BigInt(v); }; } - if (typeof(SDL3.CPtrToHeap32Index) === 'undefined') { SDL3.CPtrToHeap32Index = function(ptr) { return Number(ptr / 4n); }; } + if (typeof(SDL3.CPtrToHeap32Index) === 'undefined') { SDL3.CPtrToHeap32Index = function(ptr) { return Math.floor(Number(ptr) / 4); }; } #else #error Please define your platform. #endif diff --git a/src/video/emscripten/SDL_emscriptenvideo.c b/src/video/emscripten/SDL_emscriptenvideo.c index 7fa44acae5..cd979af8bb 100644 --- a/src/video/emscripten/SDL_emscriptenvideo.c +++ b/src/video/emscripten/SDL_emscriptenvideo.c @@ -797,7 +797,9 @@ static bool Emscripten_SetWindowIcon(SDL_VideoDevice *_this, SDL_Window *window, MAIN_THREAD_EM_ASM({ // Use `.slice` to make a copy of the data if we are dealing with a SharedArrayBuffer, or `.subarray` to create a // view into the existing buffer if its non-shared. - var pngData = HEAPU8.buffer instanceof ArrayBuffer ? HEAPU8.subarray($0, $0 + $1) : HEAPU8.slice($0, $0 + $1); + var ptr = Number($0); + var len = Number($1); + var pngData = HEAPU8.buffer instanceof ArrayBuffer ? HEAPU8.subarray(ptr, ptr + len) : HEAPU8.slice(ptr, ptr + len); var blob = new Blob([pngData], {type: 'image/png'}); var url = URL.createObjectURL(blob);