Why does modifying Leader cause the Rhino to crash?

I attempted to add control points to a Leader using the following code. The control points display correctly, but the Rhino software crashes when I try to drag any of them.

Does anyone know the reason for this issue? Alternatively, is there another method to modify the control points of a Leader? Due to the need to impose specific limitations on the draggable control points, I am compelled to use a customized approach for control points.

public class CustomLeaderGrips : CustomObjectGrips
{

private CustomLeaderGrip grips;

private Point3d m_active;

private Guid leaderId; // Field to store the ID of the Leader object

public bool CreateGrips(Leader leader, Guid leaderId)
{
    if (leader == null)
        return false;

    this.leaderId = leaderId;

    // Check if grips already exist to avoid duplication
    if (GripCount > 0)
        return false;

    // Get the points of the Leader
    var leaderPoints = leader.Points3D;

    m_active = new Point3d[leaderPoints.Length];

    // Initialize the grips array
    grips = new CustomLeaderGrip[leaderPoints.Length];
    for (int i = 0; i < leaderPoints.Length; i++)
    {
        m_active[i] = leaderPoints[i];
        grips[i] = new CustomLeaderGrip
        {
            OriginalLocation = leaderPoints[i],
            Index = i // Save the index of each grip
        };
        grips[i].Active = true; // Activate grips by default
    }

    // Add grips to CustomObjectGrips
    for (int i = 0; i < grips.Length; i++)
        AddGrip(grips[i]);

    return true;
}

protected override void OnReset()
{
    // Logic to reset grips
    base.OnReset();
}

/// <summary>
/// Update the position of grips
/// </summary>
private void UpdateGrips()
{
    if (NewLocation)
    {
        var newLeaderPoints = new List<Point3d>(GripCount);
        for (int i = 0; i < GripCount; i++)
        {
            newLeaderPoints.Add(grips[i].CurrentLocation);
        }
        Array.Copy(newLeaderPoints.ToArray(), m_active, 3);
        NewLocation = false;
    }
}

/// <summary>
/// Create a new geometric object
/// </summary>
protected override GeometryBase NewGeometry()
{
    UpdateGrips();
    if (!GripsMoved) return null;
    Leader updatedLeader = new Leader
    {
        Points3D = m_active,
    };
    // Get the current document
    var doc = RhinoDoc.ActiveDoc;

    // Find the existing Leader object
    var leaderObj = doc.Objects.Find(leaderId) as LeaderObject;
    if (leaderObj != null)
    {
        // Replace the old Leader object with the new one
        doc.Objects.Replace(leaderId, updatedLeader);
        // Dispose of the original Leader object's geometry
        leaderObj.Geometry.Dispose();
    }
    return updatedLeader;
}

protected override void OnDraw(GripsDrawEventArgs args)
{
    // Update the position of grips
    UpdateGrips();
    // Invoke the drawing method of the base class
    base.OnDraw(args);
}

}