Skip to content

Commit

Permalink
Fix race condition when aborting a WebConnection and reusing it
Browse files Browse the repository at this point in the history
  • Loading branch information
martinpotter committed Aug 18, 2017
1 parent 334807a commit d326276
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion mcs/class/System/System.Net/WebConnection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,9 @@ void ReadDone (IAsyncResult result)
{
WebConnectionData data = Data;
Stream ns = nstream;
if (ns != result.AsyncState)
return;

if (ns == null) {
Close (true);
return;
Expand Down Expand Up @@ -575,7 +578,7 @@ internal void InitRead ()

try {
int size = buffer.Length - position;
ns.BeginRead (buffer, position, size, ReadDone, null);
ns.BeginRead (buffer, position, size, ReadDone, ns);
} catch (Exception e) {
HandleError (WebExceptionStatus.ReceiveFailure, e, "InitRead");
}
Expand Down

0 comments on commit d326276

Please sign in to comment.