File tree Expand file tree Collapse file tree 1 file changed +4
-1
lines changed Expand file tree Collapse file tree 1 file changed +4
-1
lines changed Original file line number Diff line number Diff line change @@ -74,17 +74,20 @@ extension _BodyStreamSource : _BodySource {
74
74
75
75
let buffer = UnsafeMutableRawBufferPointer . allocate ( count: length)
76
76
guard let pointer = buffer. baseAddress? . assumingMemoryBound ( to: UInt8 . self) else {
77
+ buffer. deallocate ( )
77
78
return . error
78
79
}
79
80
let readBytes = self . inputStream. read ( pointer, maxLength: length)
80
81
if readBytes > 0 {
81
- let dispatchData = DispatchData ( bytes : UnsafeRawBufferPointer ( buffer) )
82
+ let dispatchData = DispatchData ( bytesNoCopy : UnsafeRawBufferPointer ( buffer) , deallocator : . free )
82
83
return . data( dispatchData. subdata ( in: 0 ..< readBytes) )
83
84
}
84
85
else if readBytes == 0 {
86
+ buffer. deallocate ( )
85
87
return . done
86
88
}
87
89
else {
90
+ buffer. deallocate ( )
88
91
return . error
89
92
}
90
93
}
You can’t perform that action at this time.
0 commit comments