diff options
author | Carol Eidt <carol.eidt@microsoft.com> | 2019-05-31 11:02:02 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-05-31 11:02:02 -0700 |
commit | 0d21b57657f8135622797f0db29460c975dd2339 (patch) | |
tree | 8f7d361c79355f08c55e700ee64d7ee35310683d /tests/src/JIT | |
parent | 795f2fd2a67047519b477cd1776626368c88e73c (diff) | |
download | coreclr-0d21b57657f8135622797f0db29460c975dd2339.tar.gz coreclr-0d21b57657f8135622797f0db29460c975dd2339.tar.bz2 coreclr-0d21b57657f8135622797f0db29460c975dd2339.zip |
Handle a zero byte cpblk (#24871)
Fix #24846
Diffstat (limited to 'tests/src/JIT')
-rw-r--r-- | tests/src/JIT/Regression/JitBlue/GitHub_24846/GitHub_24846.cs | 70 | ||||
-rw-r--r-- | tests/src/JIT/Regression/JitBlue/GitHub_24846/GitHub_24846.csproj | 18 |
2 files changed, 88 insertions, 0 deletions
diff --git a/tests/src/JIT/Regression/JitBlue/GitHub_24846/GitHub_24846.cs b/tests/src/JIT/Regression/JitBlue/GitHub_24846/GitHub_24846.cs new file mode 100644 index 0000000000..dbd276f142 --- /dev/null +++ b/tests/src/JIT/Regression/JitBlue/GitHub_24846/GitHub_24846.cs @@ -0,0 +1,70 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System; +using System.Runtime.CompilerServices; + +public class GitHub_24846 +{ + public static void Test(byte[] destination, byte[] source) + { + Unsafe.CopyBlockUnaligned(ref destination[0], ref source[0], 0); + } + + public static int Main(string[] args) + { + int returnVal = 100; + var destination = new byte[1]; + var source = new byte[1]; + try + { + Test(destination, source); + } + catch (Exception e) + { + Console.WriteLine("FAILED: " + e.Message); + returnVal = -1; + } + bool caught = false; + try + { + Test(destination, null); + } + catch (NullReferenceException e) + { + caught = true; + } + catch (Exception e) + { + Console.WriteLine("FAILED: Wrong Exception " + e.Message); + returnVal = -1; + } + if (!caught) + { + Console.WriteLine("FAILED: null destination didn't throw"); + returnVal = -1; + } + caught = false; + try + { + Test(null, source); + } + catch (NullReferenceException e) + { + caught = true; + } + catch (Exception e) + { + Console.WriteLine("FAILED: Wrong Exception " + e.Message); + returnVal = -1; + } + if (!caught) + { + Console.WriteLine("FAILED: null source didn't throw"); + returnVal = -1; + } + return returnVal; + } +} + diff --git a/tests/src/JIT/Regression/JitBlue/GitHub_24846/GitHub_24846.csproj b/tests/src/JIT/Regression/JitBlue/GitHub_24846/GitHub_24846.csproj new file mode 100644 index 0000000000..fb6ae363eb --- /dev/null +++ b/tests/src/JIT/Regression/JitBlue/GitHub_24846/GitHub_24846.csproj @@ -0,0 +1,18 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Release</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <AssemblyName>$(MSBuildProjectName)</AssemblyName> + <OutputType>Exe</OutputType> + <DebugType></DebugType> + <Optimize>True</Optimize> + <AllowUnsafeBlocks>True</AllowUnsafeBlocks> + </PropertyGroup> + <ItemGroup> + <Compile Include="$(MSBuildProjectName).cs" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "></PropertyGroup> +</Project> |