Skip to content

Commit 95c30d5

Browse files
committed
Fixed a null reference exception that could occur while calculating event hashcodes
1 parent 02b1022 commit 95c30d5

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed

src/Exceptionless/Extensions/CollectionEqualityExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public static int GetCollectionHashCode<TValue>(this IDictionary<string, TValue>
7575
var item = source[key];
7676
unchecked {
7777
var kvpHash = key.GetHashCode();
78-
kvpHash = (kvpHash * 397) ^ item.GetHashCode();
78+
kvpHash = (kvpHash * 397) ^ (item == null ? 0 : item.GetHashCode());
7979
keyValuePairHashes.Add(kvpHash);
8080
}
8181
}

src/Exceptionless/Extensions/ToErrorModelExtensions.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,11 @@ private static Error ToErrorModelInternal(Exception exception, ExceptionlessClie
7878
if (String.IsNullOrEmpty(key) || key.AnyWildcardMatches(exclusions, true))
7979
continue;
8080

81-
error.Data[key] = exception.Data[k];
81+
var item = exception.Data[k];
82+
if (item == null)
83+
continue;
84+
85+
error.Data[key] = item;
8286
}
8387
}
8488
} catch (Exception ex) {

src/Exceptionless/Extensions/ToSimpleErrorModelExtensions.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,11 @@ public static SimpleError ToSimpleErrorModel(this Exception exception, Exception
4242
if (String.IsNullOrEmpty(key) || key.AnyWildcardMatches(exclusions, true))
4343
continue;
4444

45-
error.Data[key] = exception.Data[k];
45+
var item = exception.Data[k];
46+
if (item == null)
47+
continue;
48+
49+
error.Data[key] = item;
4650
}
4751
}
4852
} catch (Exception ex) {

0 commit comments

Comments
 (0)