summaryrefslogtreecommitdiffstats
path: root/win/CS/HandBrakeWPF/Utilities
diff options
context:
space:
mode:
authorsr55 <[email protected]>2018-04-23 22:00:44 +0100
committersr55 <[email protected]>2018-04-23 22:00:44 +0100
commit7a49ab6e54a1fe6f33cf1e1ccbf46c8dd59015d1 (patch)
tree1dd4ce718f809846c8df12dca84befd1244a9f98 /win/CS/HandBrakeWPF/Utilities
parente8158b447d72735ecaf60ed4e5f3610e6673c0fa (diff)
WinGui: Fix some potential null reference exceptions in EnumHelper #1302
Diffstat (limited to 'win/CS/HandBrakeWPF/Utilities')
-rw-r--r--win/CS/HandBrakeWPF/Utilities/EnumHelper.cs15
1 files changed, 15 insertions, 0 deletions
diff --git a/win/CS/HandBrakeWPF/Utilities/EnumHelper.cs b/win/CS/HandBrakeWPF/Utilities/EnumHelper.cs
index 33469f7ba..c4ceaeb94 100644
--- a/win/CS/HandBrakeWPF/Utilities/EnumHelper.cs
+++ b/win/CS/HandBrakeWPF/Utilities/EnumHelper.cs
@@ -38,6 +38,11 @@ namespace HandBrakeWPF.Utilities
/// </returns>
public static string GetDescription(T value)
{
+ if (value == null)
+ {
+ return string.Empty;
+ }
+
FieldInfo fieldInfo = value.GetType().GetField(value.ToString());
DescriptionAttribute[] attributes =
(DescriptionAttribute[])fieldInfo.GetCustomAttributes(
@@ -52,6 +57,11 @@ namespace HandBrakeWPF.Utilities
/// <returns>A string name</returns>
public static string GetDisplay(T value)
{
+ if (value == null)
+ {
+ return string.Empty;
+ }
+
FieldInfo fieldInfo = value.GetType().GetField(value.ToString());
DisplayName[] attributes = (DisplayName[])fieldInfo.GetCustomAttributes(typeof(DisplayName), false);
@@ -108,6 +118,11 @@ namespace HandBrakeWPF.Utilities
/// </returns>
public static string GetShortName(T value)
{
+ if (value == null)
+ {
+ return string.Empty;
+ }
+
FieldInfo fieldInfo = value.GetType().GetField(value.ToString());
ShortName[] attributes = (ShortName[])fieldInfo.GetCustomAttributes(typeof(ShortName), false);