summaryrefslogtreecommitdiff
path: root/sal/osl/unx/backtraceapi.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'sal/osl/unx/backtraceapi.cxx')
-rw-r--r--sal/osl/unx/backtraceapi.cxx17
1 files changed, 10 insertions, 7 deletions
diff --git a/sal/osl/unx/backtraceapi.cxx b/sal/osl/unx/backtraceapi.cxx
index 267a331ae1c1..91be8d5d40c4 100644
--- a/sal/osl/unx/backtraceapi.cxx
+++ b/sal/osl/unx/backtraceapi.cxx
@@ -11,11 +11,13 @@
#include <cassert>
#include <cstdlib>
+#include <limits>
#include <memory>
#include <o3tl/runtimetooustring.hxx>
#include <rtl/ustrbuf.hxx>
#include <rtl/ustring.hxx>
+#include <sal/types.h>
#include "backtrace.h"
#include "backtraceasstring.hxx"
@@ -32,14 +34,15 @@ struct FreeGuard {
}
-OUString osl::detail::backtraceAsString(int maxNoStackFramesToDisplay)
-{
- assert(maxNoStackFramesToDisplay >= 0);
- if (maxNoStackFramesToDisplay == 0) {
- return OUString();
+OUString osl::detail::backtraceAsString(sal_uInt32 maxDepth) {
+ assert(maxDepth != 0);
+ auto const maxInt = static_cast<unsigned int>(
+ std::numeric_limits<int>::max());
+ if (maxDepth > maxInt) {
+ maxDepth = static_cast<sal_uInt32>(maxInt);
}
- auto b1 = std::unique_ptr<void *[]>(new void *[maxNoStackFramesToDisplay]);
- int n = backtrace(b1.get(), maxNoStackFramesToDisplay);
+ auto b1 = std::unique_ptr<void *[]>(new void *[maxDepth]);
+ int n = backtrace(b1.get(), static_cast<int>(maxDepth));
FreeGuard b2(backtrace_symbols(b1.get(), n));
b1.reset();
if (b2.buffer == nullptr) {