ScriptCode: fix stack depth precondition and add preproccessor directive checking...
authorCryptoManiac <balthazar@yandex.ru>
Sat, 29 Aug 2015 16:46:46 +0000 (19:46 +0300)
committerCryptoManiac <balthazar@yandex.ru>
Sat, 29 Aug 2015 16:46:46 +0000 (19:46 +0300)
Novacoin/Novacoin.csproj
Novacoin/ScriptCode.cs

index 2348e63..825a890 100644 (file)
@@ -15,7 +15,7 @@
     <DebugType>full</DebugType>
     <Optimize>false</Optimize>
     <OutputPath>bin\Debug</OutputPath>
-    <DefineConstants>DEBUG;</DefineConstants>
+    <DefineConstants>DEBUG;CODE_ANALYSIS;</DefineConstants>
     <ErrorReport>prompt</ErrorReport>
     <WarningLevel>4</WarningLevel>
     <ConsolePause>false</ConsolePause>
index 458445a..1b6cbea 100644 (file)
@@ -794,8 +794,8 @@ namespace Novacoin
         /// <returns>Byte sequence</returns>
         private static byte[] stacktop(ref List<byte[]> stack, int nDepth)
         {
-            Contract.Requires<StackMachineException>(nDepth < 0, "Positive stack depth makes no sense.");
-            Contract.Requires<StackMachineException>(stack.Count + nDepth > 0, "Value exceeds real stack depth.");
+            Contract.Requires<StackMachineException>(nDepth < 0, "Positive or zero stack depth makes no sense.");
+            Contract.Requires<StackMachineException>(stack.Count + nDepth >= 0, "Value exceeds real stack depth.");
 
             return stack[stack.Count + nDepth];
         }
@@ -866,8 +866,10 @@ namespace Novacoin
             var CodeQueue = script.GetByteQueue();
             var altStack = new List<byte[]>();
 
+#if !DEBUG
             try
             {
+#endif
                 instruction opcode;
                 byte[] pushArg;
 
@@ -1703,12 +1705,14 @@ namespace Novacoin
                         return false;
                     }
                 }
+#if !DEBUG
             }
             catch (Exception)
             {
                 // If there are any exceptions then just return false.
                 return false;
             }
+#endif
 
             if (vfExec.Count() != 0)
             {