aboutsummaryrefslogtreecommitdiffhomepage
path: root/testdata/map.go
diff options
context:
space:
mode:
authorDamian Gryski <[email protected]>2021-12-07 22:31:07 -0800
committerRon Evans <[email protected]>2021-12-09 18:23:49 +0100
commitd6c892fe7b0c28d3b994323bdb690257d16b332e (patch)
treeebe2ce3e4532ce7d0c8fee7089cf2534d645626c /testdata/map.go
parentcfe6b9765f90bd770aa97844bf63ca470e6237d3 (diff)
downloadtinygo-d6c892fe7b0c28d3b994323bdb690257d16b332e.tar.gz
tinygo-d6c892fe7b0c28d3b994323bdb690257d16b332e.zip
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
Diffstat (limited to 'testdata/map.go')
-rw-r--r--testdata/map.go4
1 files changed, 4 insertions, 0 deletions
diff --git a/testdata/map.go b/testdata/map.go
index 4ca456eab..7d9ee6ae8 100644
--- a/testdata/map.go
+++ b/testdata/map.go
@@ -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