Skip to content
This repository has been archived by the owner on Aug 1, 2024. It is now read-only.

Make sure negative long numbers do not crash LogRecordStreamReader #962

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Lib/ClassLibraryCommon/Analytics/LogRecordStreamReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ public void EndCurrentRecord()
}
else
{
return long.Parse(temp, NumberStyles.None, CultureInfo.InvariantCulture);
return Math.Max(0, long.Parse(temp, NumberStyles.AllowLeadingSign, CultureInfo.InvariantCulture));
Copy link
Member

Choose a reason for hiding this comment

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

Why don't we want to allow negative longs here?

Couldn't we do

return long.Parse(temp, NumberStyles.AllowLeadingSign, CultureInfo.InvariantCulture);

Choose a reason for hiding this comment

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

Yes, this should also work. The only reason to avoid negatives is that previously the framework would throw an exception, so it might be a breaking change for customer.

}
}

Expand Down