Skip to content

Commit efb46a6

Browse files
committed
null check
1 parent 6ed6d61 commit efb46a6

1 file changed

Lines changed: 10 additions & 12 deletions

File tree

FlashpointSecurePlayer/RegistryStates.cs

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -353,31 +353,29 @@ private string TestKeyDeletedInRegistryView(string keyName, RegistryView registr
353353
return keyNames.First();
354354
}
355355

356-
RegistryKey registryKeyTemp = null;
356+
RegistryKey registrySubKey = null;
357357

358358
try {
359359
for (int i = 0; i < keyNames.Count - 1; i++) {
360360
try {
361-
registryKeyTemp = registryKey.OpenSubKey(keyNames[i + 1]);
362-
363-
registryKey.Dispose();
364-
registryKey = registryKeyTemp;
361+
registrySubKey = registryKey.OpenSubKey(keyNames[i + 1]);
365362
} catch {
366-
registryKey = null;
363+
registrySubKey = null;
367364
}
368365

366+
registryKey.Dispose();
367+
registryKey = registrySubKey;
368+
369369
if (registryKey == null) {
370370
return String.Join("\\", keyNames.Take(i + 2).ToArray());
371371
}
372372
}
373-
374-
if (registryKey == null) {
375-
return keyName;
376-
}
377373
return String.Empty;
378374
} finally {
379-
registryKey.Dispose();
380-
registryKey = null;
375+
if (registryKey != null) {
376+
registryKey.Dispose();
377+
registryKey = null;
378+
}
381379
}
382380
}
383381

0 commit comments

Comments
 (0)