Skip to content

Commit

Permalink
[mediaplayer] Fix NRE in MPNowPlayingInfoCenter wrt null dictionary e…
Browse files Browse the repository at this point in the history
…ntries. 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
  • Loading branch information
spouliot authored Oct 16, 2018
1 parent e73b1a9 commit e05d87d
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions src/MediaPlayer/MPNowPlayingInfoCenter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -210,13 +210,10 @@ internal MPNowPlayingInfo (NSDictionary source)

bool TryGetValue (NSDictionary source, NSObject key, out NSObject result)
{
var b = false;
result = null;
if (key != null) {
source.TryGetValue (key, out result);
b = true;
}
return b;
if (key != null)
return source.TryGetValue (key, out result);
return false;
}
}

Expand Down

1 comment on commit e05d87d

@xamarin-release-manager
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Build was (probably) aborted

🔥 Jenkins job (on internal Jenkins) failed in stage(s) 'Build' 🔥 : hudson.AbortException: script returned exit code 2

🔥 Build failed 🔥

Please sign in to comment.