Skip to content

Commit bdf4018

Browse files
committed
[Frontend] Fix a small unique_ptr array access.
When the size of the array accessed here is zero, retrieving the address of the zero-th element here is undefined. When the frontend is linked against a libc++ that has the `unique_ptr` hardening in [this commit](llvm/llvm-project@18df9d2) enabled, it traps here. Instead, simply call `.get()` to retrieve the address of the array, which works even when it is a zero-byte allocation.
1 parent 62993ff commit bdf4018

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

lib/FrontendTool/FrontendTool.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1988,7 +1988,7 @@ int swift::performFrontend(ArrayRef<const char *> Args,
19881988
// hundreds or thousands of lines. Skip dumping this output in that case.
19891989
if (!Invocation.getFrontendOptions().InputsAndOutputs.isWholeModule()) {
19901990
for_each(configurationFileBuffers.begin(), configurationFileBuffers.end(),
1991-
&configurationFileStackTraces[0],
1991+
configurationFileStackTraces.get(),
19921992
[](const std::unique_ptr<llvm::MemoryBuffer> &buffer,
19931993
std::optional<PrettyStackTraceFileContents> &trace) {
19941994
trace.emplace(*buffer);

0 commit comments

Comments
 (0)