Skip to content

Commit

Permalink
Explicit parameter checking instead of taking First & Last
Browse files Browse the repository at this point in the history
If opcode AND operand are not null we should go into the two-parameter constructor methods.
If opcode is not null but operand is, we go into single parameter constructor method.

If both are null, the app will probably crash. :D (But it already crashes on a whole lot of invalid functions anyway lol)
  • Loading branch information
0megaD authored Apr 22, 2017
1 parent f2a951f commit 68b8405
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions dnpatch.script/Script.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 94,7 @@ private void BuildTarget()
JArray instructions = (JArray) t["instructions"];
if (instructions.Count == 1)
{
if (instructions[0].First != null && instructions[0].First.ToString() != "")
if (instructions[0]["opcode"] != null && instructions[0]["operand" != "")
{
var operand = instructions[0].Last.Last;
if (operand.Type == JTokenType.Integer)
Expand All @@ -114,7 114,7 @@ private void BuildTarget()
operand.Value<string>());
}
}
else
else if(instructions[0]["opcode"] != null)
{
target.Instruction =
Instruction.Create(
Expand Down

0 comments on commit 68b8405

Please sign in to comment.