void LinkedList :: reverseL(int val)
{
    if (val==0 || head==NULL)
    {
        return;
    }
    else
    {
    Node *temp=NULL;
    Node *curr=head;
    Node *bef=NULL;
    Node *aft=curr->next;
    for (int j=0; j<length()-val; j++)
    {
        temp=curr;
        curr=aft;
        aft=aft->next;
    }
    int i=0;
    while (curr!=NULL && i<val)
    {
        curr->next=bef;
        bef=curr;
        curr=aft;
        if (aft==NULL)
        {
            break;
        }
        if (aft!=NULL)
        {
            aft=aft->next;
        }
        i++;
    }
    temp->next=bef;
    }
}
I am just trying to figure out why I am getting a core segmentation fault for any val>=the length of the linkedlist. Can anyone point me in the right direction?
GDB shows Seg fault at temp->next=bef; Not sure how to fix that...
 
    