mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-08 13:03:39 +00:00
src/runtime: fix nil map dereference
Operations on nil maps are accepted and shouldn't panic. The base hashmapGet/hashmapDelete handled nil-maps correctly, but the hashmapBinary versions could segfault accessing the nil map while trying to hash the key. Fixes #2341
This commit is contained in:
Vendored
+4
@@ -57,6 +57,10 @@ func main() {
|
||||
println(k) // unreachable
|
||||
}
|
||||
|
||||
var nilbinmap map[uint16]int
|
||||
delete(nilbinmap, 4)
|
||||
println("nilbinmap:", nilbinmap[5])
|
||||
|
||||
arrKey := ArrayKey([4]byte{4, 3, 2, 1})
|
||||
println(testMapArrayKey[arrKey])
|
||||
testMapArrayKey[arrKey] = 5555
|
||||
|
||||
Vendored
+1
@@ -53,6 +53,7 @@ true false 0
|
||||
nilmap: 0
|
||||
4
|
||||
42
|
||||
nilbinmap: 0
|
||||
4321
|
||||
5555
|
||||
itfMap[3]: 0
|
||||
|
||||
Reference in New Issue
Block a user