I'm working with my Linked List project. But when I try to solve the arithmetic-progression testing, I got this warning from Visual Studio 2015:

> 
> Unhandled exception thrown: read access violation. q was nullptr.
> 
> 
> 

And my code:

```
struct NODE
{
    int info;
    NODE *pNext;
    NODE *pPrev;
};
struct LIST
{
    NODE *pHead;
    NODE *pTail;
};

void Init(LIST &l)
{
    l.pHead = NULL;
    l.pTail = NULL;
}
NODE *getNode(int x)
{
    NODE *p = new NODE;
    if (p == NULL)
        return NULL;
    p->info = x;
    p->pNext = NULL;
    p->pPrev = NULL;
    return p;
}
void AddTail(LIST &l, NODE *p)
{
    if (l.pHead == NULL)
        l.pHead = l.pTail = p;
    else
    {
        p->pPrev = l.pTail;
        l.pTail->pNext = p;
        l.pTail= p;
    }
}
int isEmpty(LIST l)
    {
    if (l.pHead == NULL)
        return 1;
    return 0;
}

int testArithmetic(LIST &l)
{
    int flag = 0;
    int d = l.pHead->pNext->info - l.pHead->info;
    NODE *p = l.pHead;
    while( p != NULL)
    {
        NODE *q = p->pNext;
        if (q->info - p->info == d)
            flag = 1;
        p = p->pNext;
    }
    if (flag == 0)
        return 0;
    return 1;
}

```

Can you give me some advice to deal with this problem? Thank you.