java: fix NULL pointr exception introduced by last commit. suggested by Dang Hoang Vu

This commit is contained in:
Nguyen Anh Quynh 2014-02-23 13:05:16 +08:00
parent a25a7ad231
commit bf723fa424
1 changed files with 2 additions and 4 deletions

View File

@ -275,9 +275,8 @@ public class Capstone {
private int detail;
public Capstone(int arch, int mode) {
IntByReference major = new IntByReference();
IntByReference minor = new IntByReference();
int version = cs.cs_version(major, minor);
cs = (CS)Native.loadLibrary("capstone", CS.class);
int version = cs.cs_version(null, null);
if (version != (CS_API_MAJOR << 8) + CS_API_MINOR) {
throw new RuntimeException("Different API version between core & binding (CS_ERR_VERSION)");
}
@ -285,7 +284,6 @@ public class Capstone {
this.arch = arch;
this.mode = mode;
ns = new NativeStruct();
cs = (CS)Native.loadLibrary("capstone", CS.class);
ns.handleRef = new NativeLongByReference();
if (cs.cs_open(arch, mode, ns.handleRef) != CS_ERR_OK) {
throw new RuntimeException("ERROR: Wrong arch or mode");