Skip to content

Commit ca91a5c

Browse files
authored
fix: Free memory returned by backtrace_symbols() in debug builds (#3202)
* fix: Free memory returned by backtrace_symbols() in debug builds This code is only compiled in debug builds, but we were forgetting to `free` the pointer returned by `backtrace_symbols`. The documentation (https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man3/backtrace_symbols.3.html) says: > It is allocated using malloc() and should be released using free() * Update CHANGELOG.md
1 parent 25e65a5 commit ca91a5c

2 files changed

Lines changed: 4 additions & 0 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
### Fixes
77

88
- Remove linker settings from Package.swift (#3188)
9+
- Free memory returned by backtrace_symbols() in debug builds ([#3202](https://github.com/getsentry/sentry-cocoa/pull/3202))
910

1011
## 8.9.3
1112

Sources/Sentry/Profiling/SentryProfilerState.mm

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,9 @@ - (void)appendBacktrace:(const Backtrace &)backtrace
129129
[stack addObject:frameIndex];
130130
}
131131
}
132+
# if defined(DEBUG)
133+
free(symbols);
134+
# endif
132135

133136
const auto sample = [[SentrySample alloc] init];
134137
sample.absoluteTimestamp = backtrace.absoluteTimestamp;

0 commit comments

Comments
 (0)