Skip to content

Commit

Permalink
java: verify against core's version before doing anything
Browse files Browse the repository at this point in the history
  • Loading branch information
aquynh committed Feb 23, 2014
1 parent a6d0d7a commit a25a7ad
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions bindings/java/capstone/Capstone.java
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,13 @@ protected class NativeStruct {
private int detail;

public Capstone(int arch, int mode) {
IntByReference major = new IntByReference();
IntByReference minor = new IntByReference();
int version = cs.cs_version(major, minor);
if (version != (CS_API_MAJOR << 8) + CS_API_MINOR) {
throw new RuntimeException("Different API version between core & binding (CS_ERR_VERSION)");
}

this.arch = arch;
this.mode = mode;
ns = new NativeStruct();
Expand Down

0 comments on commit a25a7ad

Please sign in to comment.