[Mono-list] Patch for crash in async operations

Elan Feingold ef10@cornell.edu
Thu, 27 Feb 2003 20:49:41 -0600


This is a multi-part message in MIME format.

------=_NextPart_000_0165_01C2DEA1.C0ECF1D0
Content-Type: text/plain;
	charset="us-ascii"
Content-Transfer-Encoding: 7bit

Any time a Worker was created with a null callback, for example:

network.BeginWrite (buffer, offset, size, null, null);

This would result in:

Unhandled Exception: System.NullReferenceException: A null value was
found where an object instance was required
in <0x000b7> 00 .Worker:End ()
in <0x00068> 00 .Worker:Send ()
in <0x0005b> 01 System.MulticastDelegate:invoke_void ()

This is because the code in Socket.cs wasn't checking for a null
callback.

My Changelog entry:

* Socket.cs: Check for a null callback before calling it.

Best regards,

-elan

------=_NextPart_000_0165_01C2DEA1.C0ECF1D0
Content-Type: application/octet-stream;
	name="patch"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
	filename="patch"

Index: class/System/System.Net.Sockets/Socket.cs=0A=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A=
RCS file: /mono/mcs/class/System/System.Net.Sockets/Socket.cs,v=0A=
retrieving revision 1.11=0A=
diff -u -b -b -r1.11 Socket.cs=0A=
--- class/System/System.Net.Sockets/Socket.cs	16 Feb 2003 22:13:26 -0000	=
1.11=0A=
+++ class/System/System.Net.Sockets/Socket.cs	28 Feb 2003 02:49:44 -0000=0A=
@@ -134,6 +134,7 @@=0A=
 			private void End() {=0A=
 				((ManualResetEvent)result.AsyncWaitHandle).Set();=0A=
 				result.IsCompleted=3Dtrue;=0A=
+				if (callback !=3D null)=0A=
 				callback(result);=0A=
 			}=0A=
 			=0A=

------=_NextPart_000_0165_01C2DEA1.C0ECF1D0--