diff options
author | Karsten Heimrich <karsten.heimrich@qt.io> | 2024-04-10 08:05:24 +0200 |
---|---|---|
committer | Karsten Heimrich <karsten.heimrich@qt.io> | 2024-04-10 12:32:40 +0000 |
commit | 94a72dd5f56c7269b084a6b3bdfa5102458bf6e6 (patch) | |
tree | 44fd8ada4c08382c72a42688933693a6da46f0f7 | |
parent | 574fa426800b9a055653f3e6fda329c92208e184 (diff) |
Fix crash while parsing mingw configuration files
Change-Id: If8f5d73a0be096f2fce09cf3a24fb5dc6fbbaf09
Reviewed-by: Ali Can Demiralp <ali.demiralp@qt.io>
Reviewed-by: Karsten Heimrich <karsten.heimrich@qt.io>
-rw-r--r-- | QtVsTools.Core/QMakeConf.cs | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/QtVsTools.Core/QMakeConf.cs b/QtVsTools.Core/QMakeConf.cs index 10d7c0e5..3023b719 100644 --- a/QtVsTools.Core/QMakeConf.cs +++ b/QtVsTools.Core/QMakeConf.cs @@ -121,7 +121,8 @@ namespace QtVsTools.Core } if (endPos > startPos) { var varName = value.Substring(startPos, endPos - startPos); - var varValue = Properties[varName] ?? string.Empty; + if (!Properties.TryGetValue(varName, out var varValue)) + varValue = ""; value = value.Substring(0, pos) + varValue + value.Substring(endPos); endPos = pos + varValue.Length; } @@ -134,11 +135,10 @@ namespace QtVsTools.Core private void RemoveValue(string key, string valueToRemove) { - if (!Properties.ContainsKey(key)) + if (!Properties.TryGetValue(key, out var value)) return; int pos; - var value = Properties[key]; do { pos = value.IndexOf(valueToRemove, StringComparison.Ordinal); if (pos >= 0) |