Skip to content

Commit

Permalink
fix: panic: http: invalid Read on closed Body (#121)
Browse files Browse the repository at this point in the history
  • Loading branch information
dunglas committed Dec 7, 2022
1 parent 229b4d6 commit 2937aa8
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions frankenphp.go
Original file line number Diff line number Diff line change
Expand Up @@ -559,11 +559,12 @@ func go_read_post(rh C.uintptr_t, cBuf *C.char, countBytes C.size_t) C.size_t {
p := make([]byte, int(countBytes))
readBytes, err := r.Body.Read(p)
if err != nil && err != io.EOF {
panic(err)
// invalid Read on closed Body may happen because of https://github.com/golang/go/issues/15527
fc, _ := FromContext(r.Context())
fc.Logger.Error("error while reading the request body", zap.Error(err))
}

if readBytes != 0 {
// todo: memory leak?
C.memcpy(unsafe.Pointer(cBuf), unsafe.Pointer(&p[0]), C.size_t(readBytes))
}

Expand Down

0 comments on commit 2937aa8

Please sign in to comment.