Skip to content

Commit 9050410

Browse files
authored
More guards against crashes in configuration processing (#1702)
1 parent c68ad37 commit 9050410

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

Extension/src/LanguageServer/configurations.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -424,10 +424,11 @@ export class CppProperties {
424424

425425
// Try to use the same configuration as before the change.
426426
let newJson: ConfigurationJson = JSON.parse(readResults);
427-
if (newJson.configurations.length === 0) {
427+
if (!newJson || !newJson.configurations || newJson.configurations.length === 0) {
428428
throw { message: "Invalid configuration file. There must be at least one configuration present in the array." };
429429
}
430-
if (!this.configurationIncomplete && newJson.configurations && this.configurationJson) {
430+
if (!this.configurationIncomplete && this.configurationJson && this.configurationJson.configurations &&
431+
this.CurrentConfiguration < this.configurationJson.configurations.length) {
431432
for (let i: number = 0; i < newJson.configurations.length; i++) {
432433
if (newJson.configurations[i].name === this.configurationJson.configurations[this.CurrentConfiguration].name) {
433434
this.currentConfigurationIndex.Value = i;

0 commit comments

Comments
 (0)