Skip to content

Commit

Permalink
GetMessageLabels() - Remove null execution path
Browse files Browse the repository at this point in the history
  • Loading branch information
abhinavminhas committed Jul 27, 2024
1 parent 25e5b6c commit 38137f4
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion GmailAPIHelper/GmailHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1277,7 +1277,7 @@ public static List<Label> GetMessageLabels(this GmailService gmailService, strin
if (messages.Count > 0)
{
var latestMessage = messages.OrderByDescending(item => item.InternalDate).FirstOrDefault();
if (latestMessage.LabelIds.Count > 0)
if (latestMessage != null && latestMessage.LabelIds.Count > 0)
{
foreach (var labelId in latestMessage.LabelIds)
{
Expand Down

0 comments on commit 38137f4

Please sign in to comment.