From d4449ed0f2eae9bd9fac3a1ad6722db70d916715 Mon Sep 17 00:00:00 2001 From: David Majnemer Date: Sat, 20 Dec 2014 08:24:43 +0000 Subject: [PATCH] strnlen isn't available on some platforms, use StringRef instead llvm-svn: 224679 --- llvm/tools/llvm-objdump/MachODump.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/llvm/tools/llvm-objdump/MachODump.cpp b/llvm/tools/llvm-objdump/MachODump.cpp index 9f5216bffae6..75ad4aa8b9b5 100644 --- a/llvm/tools/llvm-objdump/MachODump.cpp +++ b/llvm/tools/llvm-objdump/MachODump.cpp @@ -3664,7 +3664,8 @@ static void PrintLinkerOptionCommand(MachO::linker_option_command lo, if (left > 0) { i++; outs() << " string #" << i << " " << format("%.*s\n", left, string); - uint32_t len = strnlen(string, left) + 1; + uint32_t NullPos = StringRef(string, left).find('\0'); + uint32_t len = std::min(NullPos, left) + 1; string += len; left -= len; }