Skip to content

Crash because of FromJSON #4270

Closed
Closed
@secsys-go

Description

Checklist

  • I have searched the issue tracker for open issues that relate to the same problem, before opening a new one.
  • This issue only relates to a single bug. I will open new issues for any other problems.

Describe the bug

We used the Fuzz engine to modify some Test(TestFromJSON) data, and then the following crash appeared. We debugged and eventually found the crash point is at line 60 of theme/json.go. We feel that this could be an out-of-boundary bug.

How to reproduce

The simplified test code is in Example code

Screenshots

Crash log

panic: runtime error: index out of range [1] with length 1 [recovered]
	panic: runtime error: index out of range [1] with length 1

goroutine 19 [running]:
testing.tRunner.func1.2({0x6fd6a0, 0xc0000a2810})
	D:/.../go1.19/src/testing/testing.go:1396 +0x24e
testing.tRunner.func1()
	D:/.../go1.19/src/testing/testing.go:1399 +0x39f
panic({0x6fd6a0, 0xc0000a2810})
	D:/.../go1.19/src/runtime/panic.go:884 +0x212
fyne.io/fyne/v2/theme.hexColor.color({0xc00009ff28?, 0xc0002a2270?})
	D:/.../fyne/theme/json.go:60 +0x477

fyne.io/fyne/v2/theme.(*jsonTheme).Color(0xc00009c450, {0x71c7d9, 0xa}, 0x1)
	D:/.../fyne/theme/json.go:133 +0x12f
fyne.io/fyne/v2/theme.TestFromJSON2(0x0?)
	D:/.../fyne/theme/FromJSON_fuzz_test.go  :34 +0x5f
testing.tRunner(0xc000085040, 0x750c40)
	D:/.../go1.19/src/testing/testing.go:1446 +0x10b
created by testing.(*T).Run
	D:/.../go1.19/src/testing/testing.go:1493 +0x35f

Example code

repository.Register("file", intRepo.NewFileRepository()) // file uri resolving (avoid test import loop)
th, _ := FromJSON("{\"Colors\":{\"foreground\":\"\xb1\"}}")
th.Color(ColorNameForeground, VariantLight)

Fyne version

commit cfb88d7

Go compiler version

1.19

Operating system and version

Windows 10

Additional Information

No response

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    unverifiedA bug that has been reported but not verified

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions