Skip to content

Commit e05d87d

Browse files
authored
[mediaplayer] Fix NRE in MPNowPlayingInfoCenter wrt null dictionary entries. Fixes #4988 (#4992)
The custom `TryGetValue` could return `true` and an `out null`. That was fine for many items, e.g. converting `null` to `NSString` or `NSDate` is fine. However this cause an `NullReferenceException` when trying to create arrays (thru `NSArray`) or converting `NSNumber` into value types. The _normal_ `TryGetValue` behavior fixes this - and avoid extraneous (and non-required) conversions of `null` items. ref: #4988
1 parent e73b1a9 commit e05d87d

1 file changed

Lines changed: 3 additions & 6 deletions

File tree

src/MediaPlayer/MPNowPlayingInfoCenter.cs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -210,13 +210,10 @@ internal MPNowPlayingInfo (NSDictionary source)
210210

211211
bool TryGetValue (NSDictionary source, NSObject key, out NSObject result)
212212
{
213-
var b = false;
214213
result = null;
215-
if (key != null) {
216-
source.TryGetValue (key, out result);
217-
b = true;
218-
}
219-
return b;
214+
if (key != null)
215+
return source.TryGetValue (key, out result);
216+
return false;
220217
}
221218
}
222219

0 commit comments

Comments
 (0)