Skip to content

Commit 295e4f4

Browse files
committed
[Dependency Scanning] Bugfix: check for null C string before checking if it is empty
1 parent d621e22 commit 295e4f4

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

lib/DependencyScan/ScanDependencies.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -479,7 +479,7 @@ static void writePrescanJSON(llvm::raw_ostream &out,
479479
out << "{\n";
480480
SWIFT_DEFER { out << "}\n"; };
481481

482-
writeJSONSingleField(out, "imports", importSet, 0, false);
482+
writeJSONSingleField(out, "imports", importSet->imports, 0, false);
483483
}
484484

485485
static void writeJSON(llvm::raw_ostream &out,
@@ -544,11 +544,12 @@ static void writeJSON(llvm::raw_ostream &out,
544544
out.indent(4 * 2);
545545
if (swiftTextualDeps) {
546546
out << "\"swift\": {\n";
547-
548547
/// Swift interface file, if there is one. The main module, for
549548
/// example, will not have an interface file.
550549
std::string moduleInterfacePath =
551-
get_C_string(swiftTextualDeps->module_interface_path);
550+
swiftTextualDeps->module_interface_path.data
551+
? get_C_string(swiftTextualDeps->module_interface_path)
552+
: "";
552553
if (!moduleInterfacePath.empty()) {
553554
writeJSONSingleField(out, "moduleInterfacePath", moduleInterfacePath, 5,
554555
/*trailingComma=*/true);
@@ -585,7 +586,6 @@ static void writeJSON(llvm::raw_ostream &out,
585586
out.indent(5 * 2);
586587
out << "],\n";
587588
}
588-
589589
bool hasBridgingHeaderPath =
590590
swiftTextualDeps->bridging_header_path.data &&
591591
get_C_string(swiftTextualDeps->bridging_header_path)[0] != '\0';
@@ -594,7 +594,6 @@ static void writeJSON(llvm::raw_ostream &out,
594594

595595
writeJSONSingleField(out, "isFramework", swiftTextualDeps->is_framework,
596596
5, commaAfterFramework);
597-
598597
if (swiftTextualDeps->extra_pcm_args->count != 0) {
599598
out.indent(5 * 2);
600599
out << "\"extraPcmArgs\": [\n";

0 commit comments

Comments
 (0)