-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Icon/Image from Stream doesn't work for partial reads #80261
Labels
Milestone
Comments
Tagging subscribers to this area: @dotnet/area-system-drawing Issue DetailsRepro: using System.Drawing;
byte[] ico;
using (var hc = new HttpClient())
{
ico = await new HttpClient().GetByteArrayAsync(@"https://raw.githubusercontent.com/dotnet/runtime/main/src/native/corehost/dotnet/dotnet.ico");
}
var stream = new TrickleStream(ico);
new Icon(stream);
class TrickleStream : MemoryStream
{
public TrickleStream(byte[] bytes) : base(bytes) { }
public override int Read(byte[] buffer, int offset, int count) =>
base.Read(buffer, offset, Math.Min(count, count));
public override int Read(Span<byte> buffer) =>
base.Read(buffer.IsEmpty ? buffer : buffer.Slice(0, 1));
} This should successfully load the data from the Stream into the icon, but instead it throws an exception. All of these should be updated to not assume Stream.Read will return as much data as was requested.
|
Related: |
ViktorHofer
removed
the
untriaged
New issue has not been triaged by the area owner
label
Jan 23, 2023
cc @JeremyKuhne |
ghost
added
the
in-pr
There is an active PR which will close this issue when it is merged
label
Feb 24, 2023
ghost
removed
the
in-pr
There is an active PR which will close this issue when it is merged
label
Mar 2, 2023
ghost
locked as resolved and limited conversation to collaborators
Apr 1, 2023
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Repro:
This should successfully load the data from the Stream into the icon, but instead it throws an exception.
All of these should be updated to not assume Stream.Read will return as much data as was requested.
runtime/src/libraries/System.Drawing.Common/src/System/Drawing/Icon.cs
Line 75 in 1928cd2
runtime/src/libraries/System.Drawing.Common/src/System/Drawing/Icon.cs
Line 113 in 1928cd2
runtime/src/libraries/System.Drawing.Common/src/System/Drawing/Icon.cs
Line 130 in 1928cd2
runtime/src/libraries/System.Drawing.Common/src/System/Drawing/Image.cs
Line 1057 in 1928cd2
cc: @eerhardt
The text was updated successfully, but these errors were encountered: