Skip to content

Commit

Permalink
[mono-corelib] Throw exception on an invalid use of short form opcode…
Browse files Browse the repository at this point in the history
…s for locals. (dotnet#2201)
  • Loading branch information
alexischr authored and akoeplinger committed Jan 27, 2020
1 parent 6f6c94d commit db70456
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
1 change: 0 additions & 1 deletion src/mono/netcore/CoreFX.issues.rsp
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,6 @@
-noclass System.Reflection.Emit.Tests.CustomAttributeBuilderTests
-nomethod System.Reflection.Emit.Tests.SignatureHelperAddArgument.*
-nomethod System.Reflection.Emit.Tests.SignatureHelperGetPropertySigHelper.*
-nomethod System.Reflection.Emit.Tests.ILGeneratorEmit3.Emit_OpCodes_LocalBuilder_TooManyLocals_ThrowsInvalidOperationException
-nomethod System.Reflection.Emit.Tests.ILGeneratorEmit3.Emit_OpCodes_LocalBuilder_LocalFromDifferentMethod_ThrowsArgumentException
-nomethod System.Reflection.Emit.Tests.ILGeneratorDeclareLocal.DeclareLocal_TypeCreated_ThrowsInvalidOperationException
-nomethod System.Reflection.Emit.Tests.ILGeneratorDeclareLocal.DeclareLocal_GlobalFunctionsCreated_ThrowsInvalidOperationException
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -645,6 +645,9 @@ public virtual void Emit (OpCode opcode, LocalBuilder local)
throw new ArgumentException ("Trying to emit a local from a different ILGenerator.");

uint pos = local.position;
if ((opcode == OpCodes.Ldloca_S || opcode == OpCodes.Ldloc_S || opcode == OpCodes.Stloc_S) && pos > 255)
throw new InvalidOperationException ("Opcodes using a short-form index cannot address a local position over 255.");

bool load_addr = false;
bool is_store = false;
bool is_load = false;
Expand Down

0 comments on commit db70456

Please sign in to comment.