Skip to content

Commit

Permalink
[net7.0] _itemsSource may be null in CarouselViewLoopManager (#11967)
Browse files Browse the repository at this point in the history
* _itemsSource may be null

I'm seeing a NullReferenceException in this method. There are no guards against `_itemsSource` being null, so dereferencing it to get its `Count` seems likely to be the problem.

* fix dropped semicolon

Co-authored-by: Nicholas Bauer <nicholasbauer@outlook.com>
  • Loading branch information
github-actions[bot] and BioTurboNick authored Dec 8, 2022
1 parent b644a98 commit ec7280b
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ public void CenterIfNeeded(RecyclerView recyclerView, bool isHorizontal)
{
if (!(recyclerView.GetLayoutManager() is LinearLayoutManager linearLayoutManager))
return;
if (_itemsSource is null)
return;

var itemSourceCount = _itemsSource.Count;

Expand Down Expand Up @@ -43,7 +45,9 @@ public int GetGoToIndex(RecyclerView recyclerView, int carouselPosition, int new
{
if (!(recyclerView.GetLayoutManager() is LinearLayoutManager linearLayoutManager))
return -1;

if (_itemsSource is null)
return -1;

var currentCarouselPosition = carouselPosition;
var itemSourceCount = _itemsSource.Count;

Expand Down

0 comments on commit ec7280b

Please sign in to comment.