fix(‎encoding/gjson): fix gjson data race (#4510)

This commit is contained in:
Ray
2025-11-17 15:21:38 +08:00
committed by GitHub
parent a80f58b7f6
commit 072b962b81

View File

@ -142,6 +142,8 @@ func (j *Json) Contains(pattern string) bool {
// The target value by `pattern` should be type of slice or map.
// It returns -1 if the target value is not found, or its type is invalid.
func (j *Json) Len(pattern string) int {
j.mu.RLock()
defer j.mu.RUnlock()
p := j.getPointerByPattern(pattern)
if p != nil {
switch (*p).(type) {