dotnet / dotnet/aspnetcore

Potential memory leak in the MultipartReader class

Open
#57,478 0 comments 2 reactions 0 assignees View on GitHub
area-networking
Dominant language
C#
Stars
38.4k
Forks
10.9k
Avg merge
2d 6h
Merged PRs (30d)
290

Description

### Is there an existing issue for this?

- [X] I have searched the existing issues

### Describe the bug

There's a potential memory leak in the [MultipartReader](https://github.com/dotnet/aspnetcore/blob/30fb87ca055beb5997ab3f28d02bbc7866e8b683/src/Http/WebUtilities/src/MultipartReader.cs#L57) class. It creates a BufferedReadStream during the construction, but this stream is never disposed. The [BufferedReadStream](https://github.com/dotnet/aspnetcore/blob/30fb87ca055beb5997ab3f28d02bbc7866e8b683/src/Http/WebUtilities/src/BufferedReadStream.cs#L47) class in its turn rents a buffer during the construction and expects it to be returned in the Dispose method.

So the issue here is that MultipartReader leaks that buffer every time.

### Expected Behavior

MultipartReader should implement IDisposable.

### Steps To Reproduce

_No response_

### Exceptions (if any)

_No response_

### .NET Version

_No response_

### Anything else?

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.