Merge branch 'master' of github.com:aquynh/capstone
diff --git a/README.md b/README.md
index 7b9b22e..9c0954b 100644
--- a/README.md
+++ b/README.md
@@ -20,10 +20,10 @@
- Provide semantics of the disassembled instruction, such as list of implicit
registers read & written.
-- Implemented in pure C language, with lightweight bindings for Visual Basic, PHP, PowerShell,
- Emacs, Haskell, Perl, Python, Ruby, C#, NodeJS, Java, GO, C++, OCaml, Lua,
- Rust, Delphi, Free Pascal & Vala ready either in main code, or provided
- externally by the community).
+- Implemented in pure C language, with lightweight bindings for Clojure, F#,
+ Common Lisp, Visual Basic, PHP, PowerShell, Emacs, Haskell, Perl, Python,
+ Ruby, C#, NodeJS, Java, GO, C++, OCaml, Lua, Rust, Delphi, Free Pascal & Vala
+ ready either in main code, or provided externally by the community).
- Native support for all popular platforms: Windows, Mac OSX, iOS, Android,
Linux, \*BSD, Solaris, etc.
diff --git a/arch/AArch64/AArch64Mapping.c b/arch/AArch64/AArch64Mapping.c
index 6f5bbd7..4579a08 100644
--- a/arch/AArch64/AArch64Mapping.c
+++ b/arch/AArch64/AArch64Mapping.c
@@ -283,7 +283,7 @@
const char *AArch64_reg_name(csh handle, unsigned int reg)
{
#ifndef CAPSTONE_DIET
- if (reg >= ARM64_REG_ENDING)
+ if (reg >= ARR_SIZE(reg_name_maps))
return NULL;
return reg_name_maps[reg].name;
diff --git a/arch/ARM/ARMMapping.c b/arch/ARM/ARMMapping.c
index 7689839..6043dfa 100644
--- a/arch/ARM/ARMMapping.c
+++ b/arch/ARM/ARMMapping.c
@@ -245,7 +245,7 @@
const char *ARM_reg_name(csh handle, unsigned int reg)
{
#ifndef CAPSTONE_DIET
- if (reg >= ARM_REG_ENDING)
+ if (reg >= ARR_SIZE(reg_name_maps))
return NULL;
return reg_name_maps[reg].name;
@@ -257,7 +257,7 @@
const char *ARM_reg_name2(csh handle, unsigned int reg)
{
#ifndef CAPSTONE_DIET
- if (reg >= ARM_REG_ENDING)
+ if (reg >= ARR_SIZE(reg_name_maps2))
return NULL;
return reg_name_maps2[reg].name;
diff --git a/arch/M680X/M680XInstPrinter.c b/arch/M680X/M680XInstPrinter.c
index 8373e8a..23f4cb5 100644
--- a/arch/M680X/M680XInstPrinter.c
+++ b/arch/M680X/M680XInstPrinter.c
@@ -299,7 +299,7 @@
{
#ifndef CAPSTONE_DIET
- if (reg >= M680X_REG_ENDING)
+ if (reg >= ARR_SIZE(s_reg_names))
return NULL;
return s_reg_names[(int)reg];
diff --git a/arch/M68K/M68KInstPrinter.c b/arch/M68K/M68KInstPrinter.c
index 14a86e4..411e984 100644
--- a/arch/M68K/M68KInstPrinter.c
+++ b/arch/M68K/M68KInstPrinter.c
@@ -338,6 +338,9 @@
#ifdef CAPSTONE_DIET
return NULL;
#else
+ if (reg >= ARR_SIZE(s_reg_names)) {
+ return NULL;
+ }
return s_reg_names[(int)reg];
#endif
}
diff --git a/arch/Mips/MipsMapping.c b/arch/Mips/MipsMapping.c
index 01cfbc5..9f50836 100644
--- a/arch/Mips/MipsMapping.c
+++ b/arch/Mips/MipsMapping.c
@@ -201,7 +201,7 @@
const char *Mips_reg_name(csh handle, unsigned int reg)
{
#ifndef CAPSTONE_DIET
- if (reg >= MIPS_REG_ENDING)
+ if (reg >= ARR_SIZE(reg_name_maps))
return NULL;
return reg_name_maps[reg].name;
diff --git a/arch/PowerPC/PPCMapping.c b/arch/PowerPC/PPCMapping.c
index 2b2d24c..ddfcc80 100644
--- a/arch/PowerPC/PPCMapping.c
+++ b/arch/PowerPC/PPCMapping.c
@@ -234,7 +234,7 @@
const char *PPC_reg_name(csh handle, unsigned int reg)
{
#ifndef CAPSTONE_DIET
- if (reg >= PPC_REG_ENDING)
+ if (reg >= ARR_SIZE(reg_name_maps))
return NULL;
return reg_name_maps[reg].name;
diff --git a/arch/Sparc/SparcInstPrinter.c b/arch/Sparc/SparcInstPrinter.c
index 4947c9f..ebaa070 100644
--- a/arch/Sparc/SparcInstPrinter.c
+++ b/arch/Sparc/SparcInstPrinter.c
@@ -263,8 +263,6 @@
break;
}
- printInt32(O, Imm);
-
printInt64(O, Imm);
if (MI->csh->detail) {
diff --git a/arch/Sparc/SparcMapping.c b/arch/Sparc/SparcMapping.c
index 35c911e..f86fb33 100644
--- a/arch/Sparc/SparcMapping.c
+++ b/arch/Sparc/SparcMapping.c
@@ -112,7 +112,7 @@
const char *Sparc_reg_name(csh handle, unsigned int reg)
{
#ifndef CAPSTONE_DIET
- if (reg >= SPARC_REG_ENDING)
+ if (reg >= ARR_SIZE(reg_name_maps))
return NULL;
return reg_name_maps[reg].name;
diff --git a/arch/SystemZ/SystemZMapping.c b/arch/SystemZ/SystemZMapping.c
index 8e58eaf..81160e5 100644
--- a/arch/SystemZ/SystemZMapping.c
+++ b/arch/SystemZ/SystemZMapping.c
@@ -57,7 +57,7 @@
const char *SystemZ_reg_name(csh handle, unsigned int reg)
{
#ifndef CAPSTONE_DIET
- if (reg >= SYSZ_REG_ENDING)
+ if (reg >= ARR_SIZE(reg_name_maps))
return NULL;
return reg_name_maps[reg].name;
diff --git a/arch/TMS320C64x/TMS320C64xMapping.c b/arch/TMS320C64x/TMS320C64xMapping.c
index e09a49d..3a0223f 100644
--- a/arch/TMS320C64x/TMS320C64xMapping.c
+++ b/arch/TMS320C64x/TMS320C64xMapping.c
@@ -110,7 +110,7 @@
const char *TMS320C64x_reg_name(csh handle, unsigned int reg)
{
#ifndef CAPSTONE_DIET
- if (reg >= TMS320C64X_REG_ENDING)
+ if (reg >= ARR_SIZE(reg_name_maps))
return NULL;
return reg_name_maps[reg].name;
diff --git a/arch/X86/X86Mapping.c b/arch/X86/X86Mapping.c
index 3fcd1bd..ede6b6d 100644
--- a/arch/X86/X86Mapping.c
+++ b/arch/X86/X86Mapping.c
@@ -828,7 +828,7 @@
#ifndef CAPSTONE_DIET
cs_struct *ud = (cs_struct *)handle;
- if (reg >= X86_REG_ENDING)
+ if (reg >= ARR_SIZE(reg_name_maps))
return NULL;
if (reg == X86_REG_EFLAGS) {
diff --git a/arch/XCore/XCoreMapping.c b/arch/XCore/XCoreMapping.c
index e2a4c67..2a07e12 100644
--- a/arch/XCore/XCoreMapping.c
+++ b/arch/XCore/XCoreMapping.c
@@ -49,7 +49,7 @@
const char *XCore_reg_name(csh handle, unsigned int reg)
{
#ifndef CAPSTONE_DIET
- if (reg >= XCORE_REG_ENDING)
+ if (reg >= ARR_SIZE(reg_name_maps))
return NULL;
return reg_name_maps[reg].name;
diff --git a/cstool/cstool.c b/cstool/cstool.c
index 65ad945..303c553 100644
--- a/cstool/cstool.c
+++ b/cstool/cstool.c
@@ -395,6 +395,7 @@
}
cs_close(&handle);
+ free(assembly);
return 0;
}