Skip to content
This repository has been archived by the owner on Jul 22, 2024. It is now read-only.

Decoding array of slices causes panic #340

Open
nolag opened this issue Oct 19, 2023 · 0 comments
Open

Decoding array of slices causes panic #340

nolag opened this issue Oct 19, 2023 · 0 comments

Comments

@nolag
Copy link

nolag commented Oct 19, 2023

The simplest way I can re-do it is below. It causes a panic [1]

package main

import (
	"fmt"
	"github.com/mitchellh/mapstructure"
)

type Foo struct {
	B [2][]byte
}

func main() {
	f := &Foo{}
	if err := mapstructure.Decode(map[string]interface{}{"B": [2][]byte{{1, 2}, {3, 4}}}, &f); err != nil {
		panic(err)
	}
	fmt.Println(f.B)
}

[1]

panic: runtime error: comparing uncomparable type [2][]uint8

goroutine 1 [running]:
github.com/mitchellh/mapstructure.(*Decoder).decodeArray(0x1400006e1f8, {0x1012344ac, 0x1}, {0x10129cfe0, 0x14000421d10}, {0x10129cfe0?, 0x14000421cb0?, 0x1009eff8c?})
        <user>//go/pkg/mod/github.com/mitchellh/[email protected]/mapstructure.go:1164 +0x1f8
github.com/mitchellh/mapstructure.(*Decoder).decode(0x1400006e1f8, {0x1012344ac, 0x1}, {0x10129cfe0?, 0x14000421d10?}, {0x10129cfe0?, 0x14000421cb0?, 0x10095c388?})
        <user>//go/pkg/mod/github.com/mitchellh/[email protected]/mapstructure.go:490 +0x1b8
github.com/mitchellh/mapstructure.(*Decoder).decodeStructFromMap(0x1400006e1f8, {0x0, 0x0}, {0x1012c7380?, 0x14000421ce0?, 0x100964b10?}, {0x1012e9e80?, 0x14000421cb0?, 0x140005cdb18?})
        <user>//go/pkg/mod/github.com/mitchellh/[email protected]/mapstructure.go:1411 +0x718
github.com/mitchellh/mapstructure.(*Decoder).decodeStruct(0x140005cdc48?, {0x0, 0x0}, {0x1012c7380?, 0x14000421ce0?}, {0x1012e9e80?, 0x14000421cb0?, 0x6050f655bb53ef15?})
        <user>//go/pkg/mod/github.com/mitchellh/[email protected]/mapstructure.go:1235 +0x3ec
github.com/mitchellh/mapstructure.(*Decoder).decode(0x1400006e1f8, {0x0, 0x0}, {0x1012c7380?, 0x14000421ce0?}, {0x1012e9e80?, 0x14000421cb0?, 0x100964b10?})
        <user>//go/pkg/mod/github.com/mitchellh/[email protected]/mapstructure.go:482 +0x218
github.com/mitchellh/mapstructure.(*Decoder).decodePtr(0x1400006e1f8, {0x0, 0x0}, {0x1012c7380, 0x14000421ce0}, {0x101270c40?, 0x1400006e1e8?, 0x101b84130?})
        <user>//go/pkg/mod/github.com/mitchellh/[email protected]/mapstructure.go:1052 +0x3b8
github.com/mitchellh/mapstructure.(*Decoder).decode(0x1400006e1f8, {0x0, 0x0}, {0x1012c7380?, 0x14000421ce0?}, {0x101270c40?, 0x1400006e1e8?, 0x10138a120?})
        <user>//go/pkg/mod/github.com/mitchellh/[email protected]/mapstructure.go:486 +0x1e8
github.com/mitchellh/mapstructure.(*Decoder).Decode(0x1400006e1f8, {0x1012c7380, 0x14000421ce0})
        <user>//go/pkg/mod/github.com/mitchellh/[email protected]/mapstructure.go:417 +0xb8
github.com/mitchellh/mapstructure.Decode({0x1012c7380, 0x14000421ce0}, {0x101280080?, 0x1400006e1e8})
        <user>//go/pkg/mod/github.com/mitchellh/[email protected]/mapstructure.go:317 +0x8c
main.main()
        <user>//go/src/playground/entry.go:14 +0x144

nolag added a commit to nolag/mapstructure that referenced this issue Oct 30, 2023
nolag added a commit to nolag/mapstructure that referenced this issue Oct 30, 2023
nolag added a commit to nolag/mapstructure that referenced this issue Oct 30, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant