Skip to content

Commit fa33421

Browse files
authored
Defend against nil bundle identifiers (#3188)
This fixes #3184, where under some circumstances some bundles have no CFBundleIdentifier in their Info.plist.
1 parent af3a655 commit fa33421

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

Firestore/core/src/firebase/firestore/remote/grpc_root_certificate_finder_apple.mm

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,18 @@
3737

3838
namespace {
3939

40+
std::string DebugBundleIdentifier(NSBundle* _Nullable bundle) {
41+
if (!bundle) return "(nil bundle)";
42+
43+
NSString* identifier = [bundle bundleIdentifier];
44+
if (!identifier) {
45+
identifier = [bundle bundlePath];
46+
}
47+
48+
return identifier ? util::MakeString(identifier)
49+
: "(bundle with no identifier)";
50+
}
51+
4052
/**
4153
* Finds the roots.pem certificate file in the given resource bundle and logs
4254
* the outcome.
@@ -53,10 +65,10 @@
5365
if (util::LogIsDebugEnabled()) {
5466
std::string message =
5567
absl::StrCat("roots.pem ", path ? "found " : "not found ", "in bundle ",
56-
util::MakeString([bundle bundleIdentifier]));
68+
DebugBundleIdentifier(bundle));
5769
if (parent) {
58-
absl::StrAppend(&message, " (in parent ",
59-
util::MakeString([parent bundleIdentifier]), ")");
70+
absl::StrAppend(&message, " (in parent ", DebugBundleIdentifier(parent),
71+
")");
6072
}
6173
LOG_DEBUG("%s", message);
6274
}

0 commit comments

Comments
 (0)