[server] Fix a escaped heap allocation

This commit is contained in:
Ciprian Dorin Craciun 2018-11-20 16:34:17 +02:00
parent 2905bf4ef9
commit 9702cfbcb7
2 changed files with 9 additions and 1 deletions

8
.x-run
View file

@ -53,6 +53,14 @@
exit -- 1 exit -- 1
!! !!
<< go / build / server / release / analyze / escapes
"${X_RUN[@]}" ':: go / build / server / release / analyze' "${@}" \
2>&1 \
| grep -F -e ' escapes ' \
| LC_ALL=C sort -n -k 2,2 -t ':'
exit -- 0
!!
<< go / build / server / release / publish << go / build / server / release / publish
test "${#}" -eq 0 test "${#}" -eq 0

View file

@ -94,7 +94,7 @@ func (_server *server) Serve (_context *fasthttp.RequestCtx) () {
return return
} else if bytes.HasPrefix (_path, []byte ("/__/errors/banners/")) { } else if bytes.HasPrefix (_path, []byte ("/__/errors/banners/")) {
_code := _path[len ("/__/errors/banners/") :] _code := _path[len ("/__/errors/banners/") :]
if _code, _error := strconv.Atoi (BytesToString (_code)); _error == nil { if _code, _error := strconv.Atoi (BytesToString (*NoEscapeBytes (&_code))); _error == nil {
_banner, _bannerFound := ErrorBannersData[uint (_code)] _banner, _bannerFound := ErrorBannersData[uint (_code)]
if (_code > 0) && _bannerFound { if (_code > 0) && _bannerFound {
_server.ServeStatic (_context, http.StatusOK, _banner, ErrorBannerContentType, ErrorBannerContentEncoding, true) _server.ServeStatic (_context, http.StatusOK, _banner, ErrorBannerContentType, ErrorBannerContentEncoding, true)