Lachee / discord-rpc-csharp

C# custom implementation for Discord Rich Presence. Not deprecated and still available!
MIT License
560 stars 93 forks source link

Fix of ProcessMessage throwing NullPointerExceptions #196

Closed RegorForgot closed 1 year ago

RegorForgot commented 1 year ago

What the bug was

So, I kept getting NullReferenceExceptions thrown at me by the logger when the presence was activated on and off (testing behaviours for my own app when a user acts maliciously). Following the log (which I have since rather stupidly deleted), it showed that the exception was occuring at the ProcessMessage() method, which tried to merge the current presence with a possibly null one.

Since Merge() does not have null-checking, this caused the afforementioned NullReferenceException. To fix this is really easy - simply make sure that you have checked the incoming presence for null BEFORE checking whether the CURRENT presence is null (and therefore possibly causing a multitude of hair pulling bugs).

Lachee commented 1 year ago

This seems good, thank you for your contributions.