Skip to content

Commit 2029441

Browse files
committed
Bug fix to check the this CpuContext before using it
1 parent 6f2c27d commit 2029441

File tree

4 files changed

+11
-4
lines changed

4 files changed

+11
-4
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# jnitrace Change Log
22

3+
## 1.3.3
4+
- Bug fix - Checked whether the this context exists before using it
5+
36
## 1.3.2
47
- Bug fix - Use Process.findRangeByAddress instead of Process.findModuleByAddress for checking the validity of the stack pointer
58

jnitrace/src/jni/jni_env_interceptor.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,13 @@ JNIEnvInterceptor.prototype.createJNIIntercept = function(id, methodAddr) {
3737

3838
var nativeFunction = new NativeFunction(methodAddr, fridaRet, fridaArgs);
3939
var nativeCallback = new NativeCallback(function() {
40-
var threadId = this.threadId;
40+
var threadId = Process.getCurrentThreadId();
4141
var localArgs = [].slice.call(arguments);
4242
var jniEnv = self.threads.getJNIEnv(threadId);
43+
var context = null;
44+
if (this) {
45+
context = this.context;
46+
}
4347

4448
localArgs[0] = jniEnv;
4549

@@ -62,7 +66,7 @@ JNIEnvInterceptor.prototype.createJNIIntercept = function(id, methodAddr) {
6266
}
6367
}
6468

65-
self.transport.trace(method, localArgs, ret, this.context, add);
69+
self.transport.trace(method, localArgs, ret, context, add);
6670

6771
if (method.name === "GetMethodID" ||
6872
method.name === "GetStaticMethodID") {

jnitrace/src/transport/trace_transport.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ TraceTransport.prototype.trace = function(method, args, ret, context, add) {
194194

195195
// verify that a backtrace is possible.
196196
// sometimes the NativeCallback provides erroneous CpuContexts
197-
if (Process.findModuleByAddress(context.pc) &&
197+
if (context && Process.findModuleByAddress(context.pc) &&
198198
Process.findRangeByAddress(context.sp)) {
199199
var bt = Thread.backtrace(context, Backtracer.FUZZY);
200200

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
setup(
1010
name='jnitrace',
11-
version='1.3.2',
11+
version='1.3.3',
1212
description='A tool for tracing use of the JNI in Android apps',
1313
long_description=long_description,
1414
long_description_content_type='text/markdown',

0 commit comments

Comments
 (0)