Add check for out of memory
authorDionYe <junye@microsoft.com>
Fri, 15 Jan 2016 03:32:01 +0000 (11:32 +0800)
committerDionYe <junye@microsoft.com>
Mon, 18 Jan 2016 02:44:22 +0000 (10:44 +0800)
src/mscorlib/src/System/StubHelpers.cs

index 699662b..a78a158 100644 (file)
@@ -173,6 +173,11 @@ namespace  System.StubHelpers {
                     // If not provided, allocate the buffer using SysAllocStringByteLen so
                     // that odd-sized strings will be handled as well.
                     ptrToFirstChar = (byte *)Win32Native.SysAllocStringByteLen(null, lengthInBytes).ToPointer();
+
+                    if (ptrToFirstChar == null) 
+                    {
+                        throw new OutOfMemoryException();
+                    }
                 }
 
                 // copy characters from the managed string