fivem icon indicating copy to clipboard operation
fivem copied to clipboard

"==" throwing null reference exception on Models which are null

Open Keyinator opened this issue 2 years ago • 3 comments

As discovered by: https://canary.discord.com/channels/192358910387159041/553225456296525833/948031244967510067

https://github.com/citizenfx/fivem/blob/cbe56f78f86bebb68d7960a38c3cdc31c7d76790/code/client/clrcore/External/Model.cs#L405-L408 Will throw an exception if left is null since null.Equals() does not exist.

This would fix the issue:

public static bool operator ==(Model left, Model right)
{
  if (left == null)
    return right == null;

  return left.Equals(right);
}

Keyinator avatar Mar 02 '22 03:03 Keyinator

https://github.com/citizenfx/fivem/blob/cbe56f78f86bebb68d7960a38c3cdc31c7d76790/code/client/clrcore/External/Model.cs#L405-L408 This would also need to be implemented on the negation:

public static bool operator !=(Model left, Model right)
{
  return !(left==right);
}

Keyinator avatar Mar 02 '22 03:03 Keyinator

Wouldn't it be easier if you'd make a PR for this?

Sent from ProtonMail for iOS

On Wed, Mar 2, 2022 at 04:52, Keyinator @.***> wrote:

https://github.com/citizenfx/fivem/blob/cbe56f78f86bebb68d7960a38c3cdc31c7d76790/code/client/clrcore/External/Model.cs#L405-L408 This would also need to be implemented on the negation:

public static bool operator !=(Model left, Model right) { return !(left==right); }

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you are subscribed to this thread.Message ID: @.***>

blattersturm avatar Mar 02 '22 07:03 blattersturm

Wouldn't it be easier if you'd make a PR for this? Sent from ProtonMail for iOS On Wed, Mar 2, 2022 at 04:52, Keyinator @.> wrote: https://github.com/citizenfx/fivem/blob/cbe56f78f86bebb68d7960a38c3cdc31c7d76790/code/client/clrcore/External/Model.cs#L405-L408 This would also need to be implemented on the negation: public static bool operator !=(Model left, Model right) { return !(left==right); } — Reply to this email directly, [view it on GitHub](#1312 (comment)), or unsubscribe. You are receiving this because you are subscribed to this thread.Message ID: @.>

Done. #1313

Keyinator avatar Mar 02 '22 13:03 Keyinator