Skip to content

Commit b40af67

Browse files
committed
menuCommands: Protect against settingsCSV being nullptr
1 parent f1b9d22 commit b40af67

File tree

1 file changed

+22
-16
lines changed

1 file changed

+22
-16
lines changed

Firmware/RTK_Everywhere/menuCommands.ino

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1191,17 +1191,20 @@ SettingValueResponse updateSettingWithValue(bool inCommands, const char *setting
11911191
loadSettings();
11921192

11931193
// Send new settings to browser. Re-use settingsCSV to avoid stack.
1194-
memset(settingsCSV, 0, AP_CONFIG_SETTING_SIZE); // Clear any garbage from settings array
1194+
if (settingsCSV)
1195+
{
1196+
memset(settingsCSV, 0, AP_CONFIG_SETTING_SIZE); // Clear any garbage from settings array
11951197

1196-
createSettingsString(settingsCSV);
1198+
createSettingsString(settingsCSV);
11971199

1198-
if (settings.debugWebServer == true)
1199-
{
1200-
systemPrintf("Sending profile %d\r\n", settingValue);
1201-
systemPrintf("Profile contents: %s\r\n", settingsCSV);
1202-
}
1200+
if (settings.debugWebServer == true)
1201+
{
1202+
systemPrintf("Sending profile %d\r\n", settingValue);
1203+
systemPrintf("Profile contents: %s\r\n", settingsCSV);
1204+
}
12031205

1204-
webSocketsSendString(settingsCSV);
1206+
webSocketsSendString(settingsCSV);
1207+
}
12051208
knownSetting = true;
12061209
}
12071210

@@ -1229,17 +1232,20 @@ SettingValueResponse updateSettingWithValue(bool inCommands, const char *setting
12291232
activeProfiles = loadProfileNames();
12301233

12311234
// Send new settings to browser. Re-use settingsCSV to avoid stack.
1232-
memset(settingsCSV, 0, AP_CONFIG_SETTING_SIZE); // Clear any garbage from settings array
1235+
if (settingsCSV)
1236+
{
1237+
memset(settingsCSV, 0, AP_CONFIG_SETTING_SIZE); // Clear any garbage from settings array
12331238

1234-
createSettingsString(settingsCSV);
1239+
createSettingsString(settingsCSV);
12351240

1236-
if (settings.debugWebServer == true)
1237-
{
1238-
systemPrintf("Sending reset profile %d\r\n", settingValue);
1239-
systemPrintf("Profile contents: %s\r\n", settingsCSV);
1240-
}
1241+
if (settings.debugWebServer == true)
1242+
{
1243+
systemPrintf("Sending reset profile %d\r\n", settingValue);
1244+
systemPrintf("Profile contents: %s\r\n", settingsCSV);
1245+
}
12411246

1242-
webSocketsSendString(settingsCSV);
1247+
webSocketsSendString(settingsCSV);
1248+
}
12431249
knownSetting = true;
12441250
}
12451251

0 commit comments

Comments
 (0)