Skip to content

Commit

Permalink
perf(ndk init): Free allocated report info in the event of read failure
Browse files Browse the repository at this point in the history
  • Loading branch information
kattrali committed Apr 8, 2019
1 parent 5212dc1 commit 2db7765
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
### Bug fixes

* [NDK] Fix possible null pointer dereference
* [NDK] Fix possible memory leak if bugsnag-android-ndk fails to successfully
parse a cached crash report

## 4.13.0 (2019-04-03)

Expand Down
5 changes: 4 additions & 1 deletion ndk/src/main/jni/utils/serializer.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ bugsnag_report_v1 *bsg_report_v1_read(int fd) {

ssize_t len = read(fd, report, report_size);
if (len != report_size) {
free(report);
return NULL;
}
return report;
Expand All @@ -58,7 +59,8 @@ bugsnag_report *bsg_report_v2_read(int fd) {

ssize_t len = read(fd, report, report_size);
if (len != report_size) {
return NULL;
free(report);
return NULL;
}
return report;
}
Expand Down Expand Up @@ -111,6 +113,7 @@ bsg_report_header *bsg_report_header_read(int fd) {
bsg_report_header *header = malloc(sizeof(bsg_report_header));
ssize_t len = read(fd, header, sizeof(bsg_report_header));
if (len != sizeof(bsg_report_header)) {
free(header);
return NULL;
}

Expand Down

0 comments on commit 2db7765

Please sign in to comment.