Skip to content

Commit dd4a148

Browse files
committed
null check
1 parent 0e15536 commit dd4a148

1 file changed

Lines changed: 32 additions & 30 deletions

File tree

FlashpointSecurePlayer/RegistryStates.cs

Lines changed: 32 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1139,36 +1139,38 @@ public override void Activate(string templateName) {
11391139
}
11401140
break;
11411141
case TYPE.VALUE:
1142-
try {
1143-
SetValueInRegistryView(
1144-
keyName,
1145-
registryStateElement.ValueName,
1146-
String.IsNullOrEmpty(activeRegistryStateElement._ValueExpanded)
1147-
? registryStateElement.Value
1148-
: activeRegistryStateElement._ValueExpanded,
1149-
registryStateElement.ValueKind.GetValueOrDefault(),
1150-
registryView
1151-
);
1152-
} catch (SecurityException ex) {
1153-
// value exists and we can't set it
1154-
LogExceptionToLauncher(ex);
1155-
throw new TaskRequiresElevationException("Setting the value \"" + registryStateElement.ValueName + "\" in key \"" + keyName + "\" requires elevation.");
1156-
} catch (UnauthorizedAccessException ex) {
1157-
// value exists and we can't set it
1158-
LogExceptionToLauncher(ex);
1159-
throw new TaskRequiresElevationException("Setting the value \"" + registryStateElement.ValueName + "\" in key \"" + keyName + "\" requires elevation.");
1160-
} catch (FormatException ex) {
1161-
// value must be Base64
1162-
LogExceptionToLauncher(ex);
1163-
throw new InvalidRegistryStateException("The value \"" + registryStateElement.ValueName + "\" in key \"" + keyName + "\" must be Base64.");
1164-
} catch (InvalidOperationException ex) {
1165-
// value marked for deletion
1166-
LogExceptionToLauncher(ex);
1167-
throw new InvalidRegistryStateException("The value \"" + registryStateElement.ValueName + "\" in key \"" + keyName + "\" is marked for deletion.");
1168-
} catch (Exception ex) {
1169-
// value doesn't exist and can't be created
1170-
LogExceptionToLauncher(ex);
1171-
throw new InvalidRegistryStateException("The value \"" + registryStateElement.ValueName + "\" in key \"" + keyName + "\" could not be set.");
1142+
if (registryStateElement.Value != null) {
1143+
try {
1144+
SetValueInRegistryView(
1145+
keyName,
1146+
registryStateElement.ValueName,
1147+
String.IsNullOrEmpty(activeRegistryStateElement._ValueExpanded)
1148+
? registryStateElement.Value
1149+
: activeRegistryStateElement._ValueExpanded,
1150+
registryStateElement.ValueKind.GetValueOrDefault(),
1151+
registryView
1152+
);
1153+
} catch (SecurityException ex) {
1154+
// value exists and we can't set it
1155+
LogExceptionToLauncher(ex);
1156+
throw new TaskRequiresElevationException("Setting the value \"" + registryStateElement.ValueName + "\" in key \"" + keyName + "\" requires elevation.");
1157+
} catch (UnauthorizedAccessException ex) {
1158+
// value exists and we can't set it
1159+
LogExceptionToLauncher(ex);
1160+
throw new TaskRequiresElevationException("Setting the value \"" + registryStateElement.ValueName + "\" in key \"" + keyName + "\" requires elevation.");
1161+
} catch (FormatException ex) {
1162+
// value must be Base64
1163+
LogExceptionToLauncher(ex);
1164+
throw new InvalidRegistryStateException("The value \"" + registryStateElement.ValueName + "\" in key \"" + keyName + "\" must be Base64.");
1165+
} catch (InvalidOperationException ex) {
1166+
// value marked for deletion
1167+
LogExceptionToLauncher(ex);
1168+
throw new InvalidRegistryStateException("The value \"" + registryStateElement.ValueName + "\" in key \"" + keyName + "\" is marked for deletion.");
1169+
} catch (Exception ex) {
1170+
// value doesn't exist and can't be created
1171+
LogExceptionToLauncher(ex);
1172+
throw new InvalidRegistryStateException("The value \"" + registryStateElement.ValueName + "\" in key \"" + keyName + "\" could not be set.");
1173+
}
11721174
}
11731175
break;
11741176
}

0 commit comments

Comments
 (0)