MCPcopy Create free account
hub / github.com/buger/jsonparser / splitPathComponents

Function splitPathComponents

path_fuzz_test.go:119–131  ·  view source on GitHub ↗

splitPathComponents interprets the fuzz path bytes as a '/'-separated list of key components. Empty segments (from "", "a/", "/a", "a//b", etc.) become "" key components — the input shape that exposes the empty-key hazard class (8th panic site + the still-open parser.go:981 site documented as D9 in

(path []byte)

Source from the content-addressed store, hash-verified

117// multi-component paths with empty segments are reachable). Any byte
118// value would work; '/' is a human-readable default.
119func splitPathComponents(path []byte) []string {
120 s := string(path)
121 if len(s) == 0 {
122 // Empty path bytes → empty-string key component (single). This is
123 // distinct from "no keys" (which means "return the root"); the
124 // empty-string component exercises the `keys[0] == ""` hazard.
125 return []string{""}
126 }
127 if !strings.Contains(s, "/") {
128 return []string{s}
129 }
130 return strings.Split(s, "/")
131}
132
133// pathCrashCounter lets the test report how many crashes the fuzzer
134// recorded during a run. Incremented atomically-free (the fuzz worker is

Callers 6

recordPathCrashFunction · 0.85
FuzzPathMutationFunction · 0.85
FuzzSequenceFunction · 0.85
FuzzJSONStructureAwareFunction · 0.85
TestJSONFuzzCorpusSanityFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected