From da8ed1abec8a11e27e198551d428c15ad38153ec Mon Sep 17 00:00:00 2001
From: jdh8d <jdh8d@git.zephyr-software.com>
Date: Fri, 9 Mar 2018 18:40:35 +0000
Subject: [PATCH] New drops, f2null for worker, vgt testing harness updates for
 nogx,struct si. operand hasMemoryDisplacement method bulletproofed.

Former-commit-id: 6547f95c555731437fcd063cc6e1e37f02c7893e
---
 libIRDB/src/core/operand_cs.cpp | 37 ++++++++++++++++-----------------
 1 file changed, 18 insertions(+), 19 deletions(-)

diff --git a/libIRDB/src/core/operand_cs.cpp b/libIRDB/src/core/operand_cs.cpp
index 84f73896f..d2ab8e0f1 100644
--- a/libIRDB/src/core/operand_cs.cpp
+++ b/libIRDB/src/core/operand_cs.cpp
@@ -410,8 +410,7 @@ uint32_t DecodedOperandCapstone_t::getScaleValue() const
 bool DecodedOperandCapstone_t::hasMemoryDisplacement() const
 {
 
-	if (!isMemory()) 
-		return false;
+	if(!isMemory()) throw std::logic_error(string("Cannot ")+__FUNCTION__+"  of non-memory operand");
 
 	const auto the_insn = static_cast<cs_insn*>(my_insn.get());
 	const auto &op = (the_insn->detail->x86.operands[op_num]);
@@ -425,30 +424,30 @@ bool DecodedOperandCapstone_t::hasMemoryDisplacement() const
 
 	switch (mod)
 	{
-	case 0 /* 00 */:
-		if (rm == 4 &&	 // indicates SIB is present.
-			sib_base == 0x5 // indicates disp32 when sib present and mod=00.
-			)
-			return true;	// abs 32-bit
+		case 0 /* 00 */:
+			if (rm == 4 &&	 // indicates SIB is present.
+			    sib_base == 0x5 // indicates disp32 when sib present and mod=00.
+			   )
+				return true;	// abs 32-bit
 
-		if (rm == 5)
-			return true;	// pcrel or abs 32-bit depending on if 32-bit or 64-bit arch.
+			if (rm == 5)
+				return true;	// pcrel or abs 32-bit depending on if 32-bit or 64-bit arch.
 
-		return false;
+			return false;
 
-	case 1 /* 01 */:
-		return true;
+		case 1 /* 01 */:
+			return true;
 
-	case 2 /* 10 */:
-		return true;
+		case 2 /* 10 */:
+			return true;
 
-	case 3 /* 11 */:
-		return false;
+		case 3 /* 11 */:
+			return false;
 
-	default: 
-		return false;
+		default: 
+			assert(0); //unreachable
 	}
-	return false; // should be unreachable
+	assert(0); // unreachable
 } // end of DecodedOperandCapstone_t::hasMemoryDisplacement()
 
 virtual_offset_t DecodedOperandCapstone_t::getMemoryDisplacement() const
-- 
GitLab