# Patch created by krokas
# Date: Thu Aug 31 01:02:31 MSD 2006
# Repository: pnetlib
# Comments:
# 
#### End of Preamble ####

#### Patch data follows ####
Index: runtime/System/Runtime/InteropServices/Marshal.cs
===================================================================
RCS file: /sources/dotgnu-pnet/pnetlib/runtime/System/Runtime/InteropServices/Marshal.cs,v
retrieving revision 1.12
diff -c -r1.12 Marshal.cs
*** runtime/System/Runtime/InteropServices/Marshal.cs	9 Jun 2003 22:15:09 -0000	1.12
--- runtime/System/Runtime/InteropServices/Marshal.cs	30 Aug 2006 21:02:23 -0000
***************
*** 70,84 ****
  				{
  					throw new ArgumentNullException("destination");
  				}
  				if(startIndex < 0 || startIndex > source.Length)
  				{
  					throw new ArgumentOutOfRangeException
  						("startIndex", _("ArgRange_Array"));
  				}
! 				if(length < 0 || (source.Length - startIndex) < length)
  				{
! 					throw new ArgumentOutOfRangeException
! 						("length", _("ArgRange_Array"));
  				}
  				CopyMU(source, startIndex, destination, length);
  			}
--- 70,91 ----
  				{
  					throw new ArgumentNullException("destination");
  				}
+ 				if(length == 0)
+ 				{
+ 					return;
+ 				}
  				if(startIndex < 0 || startIndex > source.Length)
  				{
  					throw new ArgumentOutOfRangeException
  						("startIndex", _("ArgRange_Array"));
  				}
! 				if(length < 0)
  				{
! 					return;
! 				}
! 				if((source.Length - startIndex) < length)
! 				{
! 					length = source.Length - startIndex;
  				}
  				CopyMU(source, startIndex, destination, length);
  			}
***************
*** 87,108 ****
  			{
  				if(source == null)
  				{
! 					throw new ArgumentNullException("source");
  				}
  				if(destination == IntPtr.Zero)
  				{
  					throw new ArgumentNullException("destination");
  				}
  				if(startIndex < 0 || startIndex > source.Length)
  				{
  					throw new ArgumentOutOfRangeException
  						("startIndex", _("ArgRange_Array"));
  				}
! 				if(length < 0 || (source.Length - startIndex) < length)
  				{
  					throw new ArgumentOutOfRangeException
  						("length", _("ArgRange_Array"));
  				}
  				CopyMU(source, startIndex * 2, destination, length * 2);
  			}
  	public static void Copy(double[] source, int startIndex,
--- 94,123 ----
  			{
  				if(source == null)
  				{
! 					return;
  				}
  				if(destination == IntPtr.Zero)
  				{
  					throw new ArgumentNullException("destination");
  				}
+ 				if(length == 0)
+ 				{
+ 					return;
+ 				}
  				if(startIndex < 0 || startIndex > source.Length)
  				{
  					throw new ArgumentOutOfRangeException
  						("startIndex", _("ArgRange_Array"));
  				}
! 				if(length < 0)
  				{
  					throw new ArgumentOutOfRangeException
  						("length", _("ArgRange_Array"));
  				}
+ 				if((source.Length - startIndex) < length)
+ 				{
+ 					length = source.Length - startIndex;
+ 				}
  				CopyMU(source, startIndex * 2, destination, length * 2);
  			}
  	public static void Copy(double[] source, int startIndex,
***************
*** 116,131 ****
  				{
  					throw new ArgumentNullException("destination");
  				}
  				if(startIndex < 0 || startIndex > source.Length)
  				{
  					throw new ArgumentOutOfRangeException
  						("startIndex", _("ArgRange_Array"));
  				}
! 				if(length < 0 || (source.Length - startIndex) < length)
  				{
  					throw new ArgumentOutOfRangeException
  						("length", _("ArgRange_Array"));
  				}
  				CopyMU(source, startIndex * 8, destination, length * 8);
  			}
  	public static void Copy(float[] source, int startIndex,
--- 131,154 ----
  				{
  					throw new ArgumentNullException("destination");
  				}
+ 				if(length == 0)
+ 				{
+ 					return;
+ 				}
  				if(startIndex < 0 || startIndex > source.Length)
  				{
  					throw new ArgumentOutOfRangeException
  						("startIndex", _("ArgRange_Array"));
  				}
! 				if(length < 0)
  				{
  					throw new ArgumentOutOfRangeException
  						("length", _("ArgRange_Array"));
  				}
+ 				if((source.Length - startIndex) < length)
+ 				{
+ 					length = source.Length - startIndex - length;
+ 				}
  				CopyMU(source, startIndex * 8, destination, length * 8);
  			}
  	public static void Copy(float[] source, int startIndex,
***************
*** 139,153 ****
  				{
  					throw new ArgumentNullException("destination");
  				}
  				if(startIndex < 0 || startIndex > source.Length)
  				{
  					throw new ArgumentOutOfRangeException
  						("startIndex", _("ArgRange_Array"));
  				}
! 				if(length < 0 || (source.Length - startIndex) < length)
  				{
! 					throw new ArgumentOutOfRangeException
! 						("length", _("ArgRange_Array"));
  				}
  				CopyMU(source, startIndex * 4, destination, length * 4);
  			}
--- 162,183 ----
  				{
  					throw new ArgumentNullException("destination");
  				}
+ 				if(length == 0)
+ 				{
+ 					return;
+ 				}
  				if(startIndex < 0 || startIndex > source.Length)
  				{
  					throw new ArgumentOutOfRangeException
  						("startIndex", _("ArgRange_Array"));
  				}
! 				if(length < 0)
  				{
! 					return;
! 				}
! 				if((source.Length - startIndex) < length)
! 				{
! 					length = source.Length - startIndex;
  				}
  				CopyMU(source, startIndex * 4, destination, length * 4);
  			}
***************
*** 156,177 ****
  			{
  				if(source == null)
  				{
! 					throw new ArgumentNullException("source");
  				}
  				if(destination == IntPtr.Zero)
  				{
! 					throw new ArgumentNullException("destination");
  				}
  				if(startIndex < 0 || startIndex > source.Length)
  				{
  					throw new ArgumentOutOfRangeException
  						("startIndex", _("ArgRange_Array"));
  				}
! 				if(length < 0 || (source.Length - startIndex) < length)
  				{
  					throw new ArgumentOutOfRangeException
  						("length", _("ArgRange_Array"));
  				}
  				CopyMU(source, startIndex * 4, destination, length * 4);
  			}
  	public static void Copy(long[] source, int startIndex,
--- 186,215 ----
  			{
  				if(source == null)
  				{
! 					return;
  				}
  				if(destination == IntPtr.Zero)
  				{
! 					return;
! 				}
! 				if(length == 0)
! 				{
! 					return;
  				}
  				if(startIndex < 0 || startIndex > source.Length)
  				{
  					throw new ArgumentOutOfRangeException
  						("startIndex", _("ArgRange_Array"));
  				}
! 				if(length < 0)
  				{
  					throw new ArgumentOutOfRangeException
  						("length", _("ArgRange_Array"));
  				}
+ 				if((source.Length - startIndex) < length)
+ 				{
+ 					length = source.Length - startIndex;
+ 				}
  				CopyMU(source, startIndex * 4, destination, length * 4);
  			}
  	public static void Copy(long[] source, int startIndex,
***************
*** 185,200 ****
  				{
  					throw new ArgumentNullException("destination");
  				}
  				if(startIndex < 0 || startIndex > source.Length)
  				{
  					throw new ArgumentOutOfRangeException
  						("startIndex", _("ArgRange_Array"));
  				}
! 				if(length < 0 || (source.Length - startIndex) < length)
  				{
  					throw new ArgumentOutOfRangeException
  						("length", _("ArgRange_Array"));
  				}
  				CopyMU(source, startIndex * 8, destination, length * 8);
  			}
  	public static void Copy(short[] source, int startIndex,
--- 223,246 ----
  				{
  					throw new ArgumentNullException("destination");
  				}
+ 				if(length == 0)
+ 				{
+ 					return;
+ 				}
  				if(startIndex < 0 || startIndex > source.Length)
  				{
  					throw new ArgumentOutOfRangeException
  						("startIndex", _("ArgRange_Array"));
  				}
! 				if(length < 0)
  				{
  					throw new ArgumentOutOfRangeException
  						("length", _("ArgRange_Array"));
  				}
+ 				if((source.Length - startIndex) < length)
+ 				{
+ 					length = source.Length - startIndex;
+ 				}
  				CopyMU(source, startIndex * 8, destination, length * 8);
  			}
  	public static void Copy(short[] source, int startIndex,
***************
*** 202,223 ****
  			{
  				if(source == null)
  				{
! 					throw new ArgumentNullException("source");
  				}
  				if(destination == IntPtr.Zero)
  				{
! 					throw new ArgumentNullException("destination");
  				}
  				if(startIndex < 0 || startIndex > source.Length)
  				{
  					throw new ArgumentOutOfRangeException
  						("startIndex", _("ArgRange_Array"));
  				}
! 				if(length < 0 || (source.Length - startIndex) < length)
  				{
  					throw new ArgumentOutOfRangeException
  						("length", _("ArgRange_Array"));
  				}
  				CopyMU(source, startIndex * 2, destination, length * 2);
  			}
  
--- 248,277 ----
  			{
  				if(source == null)
  				{
! 					throw new ArgumentNullException("startIndex");
  				}
  				if(destination == IntPtr.Zero)
  				{
! 					return;
! 				}
! 				if(length == 0)
! 				{
! 					return;
  				}
  				if(startIndex < 0 || startIndex > source.Length)
  				{
  					throw new ArgumentOutOfRangeException
  						("startIndex", _("ArgRange_Array"));
  				}
! 				if(length < 0)
  				{
  					throw new ArgumentOutOfRangeException
  						("length", _("ArgRange_Array"));
  				}
+ 				if((source.Length - startIndex) < length)
+ 				{
+ 					length = source.Length - startIndex;
+ 				}
  				CopyMU(source, startIndex * 2, destination, length * 2);
  			}
  
***************
*** 238,252 ****
  				{
  					throw new ArgumentNullException("destination");
  				}
  				if(startIndex < 0 || startIndex > destination.Length)
  				{
! 					throw new ArgumentOutOfRangeException
! 						("startIndex", _("ArgRange_Array"));
  				}
! 				if(length < 0 || (destination.Length - startIndex) < length)
  				{
! 					throw new ArgumentOutOfRangeException
! 						("length", _("ArgRange_Array"));
  				}
  				CopyUM(source, destination, startIndex, length);
  			}
--- 292,308 ----
  				{
  					throw new ArgumentNullException("destination");
  				}
+ 				if(length <= 0)
+ 				{
+ 					return;
+ 				}
  				if(startIndex < 0 || startIndex > destination.Length)
  				{
! 					return;
  				}
! 				if((destination.Length - startIndex) < length)
  				{
! 					length = destination.Length - startIndex;
  				}
  				CopyUM(source, destination, startIndex, length);
  			}
***************
*** 261,275 ****
  				{
  					throw new ArgumentNullException("destination");
  				}
  				if(startIndex < 0 || startIndex > destination.Length)
  				{
! 					throw new ArgumentOutOfRangeException
! 						("startIndex", _("ArgRange_Array"));
  				}
! 				if(length < 0 || (destination.Length - startIndex) < length)
  				{
! 					throw new ArgumentOutOfRangeException
! 						("length", _("ArgRange_Array"));
  				}
  				CopyUM(source, destination, startIndex * 2, length * 2);
  			}
--- 317,333 ----
  				{
  					throw new ArgumentNullException("destination");
  				}
+ 				if(length <= 0)
+ 				{
+ 					return;
+ 				}
  				if(startIndex < 0 || startIndex > destination.Length)
  				{
! 					return;
  				}
! 				if((destination.Length - startIndex) < length)
  				{
! 					length = destination.Length - startIndex;
  				}
  				CopyUM(source, destination, startIndex * 2, length * 2);
  			}
***************
*** 284,298 ****
  				{
  					throw new ArgumentNullException("destination");
  				}
  				if(startIndex < 0 || startIndex > destination.Length)
  				{
! 					throw new ArgumentOutOfRangeException
! 						("startIndex", _("ArgRange_Array"));
  				}
! 				if(length < 0 || (destination.Length - startIndex) < length)
  				{
! 					throw new ArgumentOutOfRangeException
! 						("length", _("ArgRange_Array"));
  				}
  				CopyUM(source, destination, startIndex * 8, length * 8);
  			}
--- 342,358 ----
  				{
  					throw new ArgumentNullException("destination");
  				}
+ 				if(length <= 0)
+ 				{
+ 					return;
+ 				}
  				if(startIndex < 0 || startIndex > destination.Length)
  				{
! 					return;
  				}
! 				if((destination.Length - startIndex) < length)
  				{
! 					length = destination.Length - startIndex;
  				}
  				CopyUM(source, destination, startIndex * 8, length * 8);
  			}
***************
*** 307,321 ****
  				{
  					throw new ArgumentNullException("destination");
  				}
! 				if(startIndex < 0 || startIndex > destination.Length)
  				{
! 					throw new ArgumentOutOfRangeException
! 						("startIndex", _("ArgRange_Array"));
  				}
! 				if(length < 0 || (destination.Length - startIndex) < length)
  				{
! 					throw new ArgumentOutOfRangeException
! 						("length", _("ArgRange_Array"));
  				}
  				CopyUM(source, destination, startIndex * 4, length * 4);
  			}
--- 367,383 ----
  				{
  					throw new ArgumentNullException("destination");
  				}
! 				if(length <= 0)
  				{
! 					return;
  				}
! 				if(startIndex < 0 || (startIndex > destination.Length))
  				{
! 					return;
! 				}
! 				if((destination.Length - startIndex) < length)
! 				{
! 					length = destination.Length - startIndex;
  				}
  				CopyUM(source, destination, startIndex * 4, length * 4);
  			}
***************
*** 330,344 ****
  				{
  					throw new ArgumentNullException("destination");
  				}
  				if(startIndex < 0 || startIndex > destination.Length)
  				{
! 					throw new ArgumentOutOfRangeException
! 						("startIndex", _("ArgRange_Array"));
  				}
! 				if(length < 0 || (destination.Length - startIndex) < length)
  				{
! 					throw new ArgumentOutOfRangeException
! 						("length", _("ArgRange_Array"));
  				}
  				CopyUM(source, destination, startIndex * 4, length * 4);
  			}
--- 392,408 ----
  				{
  					throw new ArgumentNullException("destination");
  				}
+ 				if(length <= 0)
+ 				{
+ 					return;
+ 				}
  				if(startIndex < 0 || startIndex > destination.Length)
  				{
! 					return;
  				}
! 				if((destination.Length - startIndex) < length)
  				{
! 					length = destination.Length - startIndex;
  				}
  				CopyUM(source, destination, startIndex * 4, length * 4);
  			}
***************
*** 353,367 ****
  				{
  					throw new ArgumentNullException("destination");
  				}
  				if(startIndex < 0 || startIndex > destination.Length)
  				{
! 					throw new ArgumentOutOfRangeException
! 						("startIndex", _("ArgRange_Array"));
  				}
! 				if(length < 0 || (destination.Length - startIndex) < length)
  				{
! 					throw new ArgumentOutOfRangeException
! 						("length", _("ArgRange_Array"));
  				}
  				CopyUM(source, destination, startIndex * 8, length * 8);
  			}
--- 417,433 ----
  				{
  					throw new ArgumentNullException("destination");
  				}
+ 				if(length <= 0)
+ 				{
+ 					return;
+ 				}
  				if(startIndex < 0 || startIndex > destination.Length)
  				{
! 					return;
  				}
! 				if((destination.Length - startIndex) < length)
  				{
! 					length = destination.Length - startIndex;
  				}
  				CopyUM(source, destination, startIndex * 8, length * 8);
  			}
***************
*** 376,390 ****
  				{
  					throw new ArgumentNullException("destination");
  				}
  				if(startIndex < 0 || startIndex > destination.Length)
  				{
! 					throw new ArgumentOutOfRangeException
! 						("startIndex", _("ArgRange_Array"));
  				}
! 				if(length < 0 || (destination.Length - startIndex) < length)
  				{
! 					throw new ArgumentOutOfRangeException
! 						("length", _("ArgRange_Array"));
  				}
  				CopyUM(source, destination, startIndex * 2, length * 2);
  			}
--- 442,458 ----
  				{
  					throw new ArgumentNullException("destination");
  				}
+ 				if(length <= 0)
+ 				{
+ 					return;
+ 				}
  				if(startIndex < 0 || startIndex > destination.Length)
  				{
! 					return;
  				}
! 				if((destination.Length - startIndex) < length)
  				{
! 					length = destination.Length - startIndex;
  				}
  				CopyUM(source, destination, startIndex * 2, length * 2);
  			}
#### End of Patch data ####
