Skip to content

Commit

Permalink
Merge pull request #1484 from bugsnag/PLAT-7529/stackframe-fix
Browse files Browse the repository at this point in the history
Increase resilience of NDK stackframe method capture
  • Loading branch information
fractalwrench authored Nov 8, 2021
2 parents d1b17b8 + 3063cf0 commit cf8e225
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

### Bug fixes

* Increase resilience of NDK stackframe method capture
[#1484](https://github.com/bugsnag/bugsnag-android/pull/1484)

* Avoid reporting false-positive background ANRs with improved foreground detection
[#1429](https://github.com/bugsnag/bugsnag-android/pull/1429)

Expand Down
17 changes: 13 additions & 4 deletions bugsnag-plugin-android-ndk/src/main/jni/bugsnag.c
Original file line number Diff line number Diff line change
Expand Up @@ -81,16 +81,25 @@ void bsg_populate_notify_stacktrace(JNIEnv *env, bugsnag_stackframe *stacktrace,
goto exit;
}

// populate filename
jstring filename = bsg_safe_new_string_utf(env, frame.filename);
jstring method;
if (filename == NULL) {
goto exit;
}

// populate method
jstring method = NULL;
if (strlen(frame.method) == 0) {
char *frame_address = calloc(1, sizeof(char) * 32);
sprintf(frame_address, "0x%lx", (unsigned long)frame.frame_address);
char frame_address[32];
snprintf(frame_address, sizeof(frame_address), "0x%lx",
(unsigned long)frame.frame_address);
method = bsg_safe_new_string_utf(env, frame_address);
free(frame_address);
} else {
method = bsg_safe_new_string_utf(env, frame.method);
}
if (method == NULL) {
goto exit;
}

// create StackTraceElement object
jobject jframe =
Expand Down

0 comments on commit cf8e225

Please sign in to comment.