From aead324676d997c30aac2851f4a37125db195d3e Mon Sep 17 00:00:00 2001
From: Cyrille Bagard <nocbos@gmail.com>
Date: Fri, 28 Apr 2017 22:24:01 +0200
Subject: Rewritten some security checks when printing immediate values.

---
 ChangeLog            | 5 +++++
 src/arch/immediate.c | 5 +++--
 src/arch/immediate.h | 3 +++
 3 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index cb6fff4..5c46e8c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,11 @@
 17-04-28  Cyrille Bagard <nocbos@gmail.com>
 
 	* src/arch/immediate.c:
+	Rewrite some security checks when printing immediate values.
+
+17-04-28  Cyrille Bagard <nocbos@gmail.com>
+
+	* src/arch/immediate.c:
 	Escape some characters as needed when building tooltips.
 
 17-04-28  Cyrille Bagard <nocbos@gmail.com>
diff --git a/src/arch/immediate.c b/src/arch/immediate.c
index 88426de..a6f080f 100644
--- a/src/arch/immediate.c
+++ b/src/arch/immediate.c
@@ -893,7 +893,7 @@ static size_t _g_imm_operand_to_string(const GImmOperand *operand, AsmSyntax syn
     static const char *conv_si_defs[] = { "", "o", "d", "x", "c" };
     static const char *conv_us_defs[] = { "", "o", "u", "x", "c" };
 
-    result = 0; /* Gcc... */
+    assert(display <= IOD_LAST_VALID);
 
     range = MDS_RANGE(operand->size);
 
@@ -1042,11 +1042,12 @@ static size_t _g_imm_operand_to_string(const GImmOperand *operand, AsmSyntax syn
 
         default:
             assert(false);
+            result = 0;
             break;
 
     }
 
-    assert(((int)result) > 0);
+    assert(result > 0);
 
     return result;
 
diff --git a/src/arch/immediate.h b/src/arch/immediate.h
index b4d1f84..450ceef 100644
--- a/src/arch/immediate.h
+++ b/src/arch/immediate.h
@@ -54,6 +54,9 @@ typedef enum _ImmOperandDisplay
 } ImmOperandDisplay;
 
 
+#define IOD_LAST_VALID IOD_CHAR
+
+
 #define G_TYPE_IMM_OPERAND               g_imm_operand_get_type()
 #define G_IMM_OPERAND(obj)               (G_TYPE_CHECK_INSTANCE_CAST((obj), g_imm_operand_get_type(), GImmOperand))
 #define G_IS_IMM_OPERAND(obj)            (G_TYPE_CHECK_INSTANCE_TYPE((obj), g_imm_operand_get_type()))
-- 
cgit v0.11.2-87-g4458