fix: g711 override memory

fix: PacketizeRTP memory leak
fix: avoid read files beyond the log path
This commit is contained in:
langhuihui
2023-05-25 19:12:01 +08:00
parent d3b26d69fc
commit fc7ac81c4e
13 changed files with 132 additions and 40 deletions

View File

@@ -21,8 +21,11 @@ func ReturnJson[T any](fetch func() T, tickDur time.Duration, rw http.ResponseWr
return
}
}
} else if err := json.NewEncoder(rw).Encode(fetch()); err != nil {
http.Error(rw, err.Error(), http.StatusInternalServerError)
} else {
rw.Header().Set("Content-Type", "application/json")
if err := json.NewEncoder(rw).Encode(fetch()); err != nil {
http.Error(rw, err.Error(), http.StatusInternalServerError)
}
}
}
@@ -36,8 +39,11 @@ func ReturnYaml[T any](fetch func() T, tickDur time.Duration, rw http.ResponseWr
return
}
}
} else if err := yaml.NewEncoder(rw).Encode(fetch()); err != nil {
http.Error(rw, err.Error(), http.StatusInternalServerError)
} else {
rw.Header().Set("Content-Type", "application/yaml")
if err := yaml.NewEncoder(rw).Encode(fetch()); err != nil {
http.Error(rw, err.Error(), http.StatusInternalServerError)
}
}
}