aports/community/chawan/fix-test-localstorage.patch

29 lines
1.1 KiB
Diff

Patch-Source: https://git.sr.ht/~bptato/chawan/commit/6f0549555465a5fa63548d2e9a52348c7763aade
---
From 6f0549555465a5fa63548d2e9a52348c7763aade Mon Sep 17 00:00:00 2001
From: bptato <nincsnevem662@gmail.com>
Date: Thu, 22 Jan 2026 21:26:57 +0100
Subject: [PATCH] env: fix overflow check in Storage#key on 32-bit
---
src/html/env.nim | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/html/env.nim b/src/html/env.nim
index 474ec85047061c51935d9c6a63e5fb23e2a9260a..6597728604c110b491d3192cecd057448ebbe421 100644
--- a/src/html/env.nim
+++ b/src/html/env.nim
@@ -141,9 +141,9 @@ proc find(this: Storage; key: string): int =
proc length(this: Storage): uint32 {.jsfget.} =
return uint32(this.map.len)
-proc key(ctx: JSContext; this: Storage; i: uint32): JSValue {.jsfunc.} =
- if int(i) < this.map.len:
- return ctx.toJS(this.map[int(i)].key)
+proc key(ctx: JSContext; this: Storage; u: uint32): JSValue {.jsfunc.} =
+ if u < uint32(this.map.len):
+ return ctx.toJS(this.map[int(u)].key)
return JS_NULL
proc getItem(ctx: JSContext; this: Storage; s: string): JSValue {.jsfunc.} =