Skip to content

Commit 6b43f1d

Browse files
smilesa-maurice
authored andcommitted
Fix crash when retrieving mock configuration on iOS.
If configuration wasn't set for a mock / fake class, ConfigGet() would previously crash. This change modifies the method to optionally retrieve configuration from the FlatBuffer. PiperOrigin-RevId: 264635894
1 parent b80fcc5 commit 6b43f1d

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

testing/config_ios.mm

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,11 @@ void ConfigSet(const char* test_data_in_json) {
3535
const TestDataConfig* config = GetTestDataConfig(g_test_data_config);
3636
// LookupByKey() does not work because the data passed in may not conform. So
3737
// we just iterate over the test data.
38-
for (const ConfigRow* row : *(config->config())) {
39-
if (strcmp(row->fake()->c_str(), fake) == 0) {
40-
return row;
38+
if (config->config()) {
39+
for (const ConfigRow* row : *(config->config())) {
40+
if (row->fake() && strcmp(row->fake()->c_str(), fake) == 0) {
41+
return row;
42+
}
4143
}
4244
}
4345
return nullptr;

0 commit comments

Comments
 (0)