Skip to content

Commit 6288b31

Browse files
authored
PropertyGridView: Prevent out-of-range access when committing next enumerable value (#14182)
## Proposed changes - Update method `DoubleClickRow` and `OnMouseWheel`: After calling `gridEntry.GetPropertyValueList()`, check `values.Length > 0` before trying to access `values[index]`. ## Customer Impact - Prevents IndexOutOfRangeException or similar crashes when users double‑click or scroll a PropertyGrid entry whose StandardValues list becomes empty at commit time.
1 parent a8bb1e7 commit 6288b31

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

  • src/System.Windows.Forms/System/Windows/Forms/Controls/PropertyGrid/PropertyGridInternal

src/System.Windows.Forms/System/Windows/Forms/Controls/PropertyGrid/PropertyGridInternal/PropertyGridView.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1298,6 +1298,12 @@ public void DoubleClickRow(int row, bool toggleExpand, int type)
12981298
{
12991299
object[] values = gridEntry.GetPropertyValueList();
13001300

1301+
// If values.Length is 0, we can't cycle through anything.
1302+
if (values.Length == 0)
1303+
{
1304+
return;
1305+
}
1306+
13011307
if (index >= (values.Length - 1))
13021308
{
13031309
index = 0;
@@ -3177,6 +3183,12 @@ protected override void OnMouseWheel(MouseEventArgs e)
31773183
int delta = e.Delta > 0 ? -1 : 1;
31783184
object[] values = _selectedGridEntry.GetPropertyValueList();
31793185

3186+
// Prevent out-of-range access
3187+
if (values.Length == 0)
3188+
{
3189+
return;
3190+
}
3191+
31803192
if (delta > 0 && index >= (values.Length - 1))
31813193
{
31823194
index = 0;

0 commit comments

Comments
 (0)