Skip to content

Commit 144bc49

Browse files
committed
Harden against the missing message in generate_reproducer.
1 parent 127cb89 commit 144bc49

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

Sources/SWBCSupport/CLibclang.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2183,7 +2183,7 @@ extern "C" {
21832183
argc, const_cast<const char**>(argv), workingDirectory,
21842184
/*ReproducerLocation=*/NULL, /*UseUniqueReproducerName=*/true, &messageString);
21852185
if (message) {
2186-
*message = strdup(lib->fns.clang_getCString(messageString));
2186+
*message = strdup_safe(lib->fns.clang_getCString(messageString));
21872187
}
21882188
lib->fns.clang_disposeString(messageString);
21892189
return result == LibclangFunctions::CXError_Success;

Sources/SWBCore/LibclangVendored/Libclang.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ public final class DependencyScanner {
285285
let success = libclang_scanner_generate_reproducer(scanner, CInt(args.cArray.count - 1), args.cArray, workingDirectory, &messageUnsafe);
286286
let message = String(cString: messageUnsafe)
287287
guard success else {
288-
throw Error.dependencyScanErrorString(message)
288+
throw message.isEmpty ? Error.dependencyScanUnknownError : Error.dependencyScanErrorString(message)
289289
}
290290
return message
291291
}

0 commit comments

Comments
 (0)