链表的插入问题,提交oj显示运行错误,不知道怎么改对😥

void insert(struct node *H,int p)
{
struct node *pr=H;
struct node node;
node=(struct node
)malloc(sizeof(struct node));
while(pr->next ->x<p)
{
pr=pr->next;
}
node->next =pr->next ;
node->x =p;
pr->next =node;

}

malloc有问题:
应该是struct node* node = (struct node*)malloc(sizeof(struct node));
而且还需要判断是否为NULL

void insert(struct node* H, int p)
{
    struct node* pr = H;
    struct node* node = (struct node*)malloc(sizeof(struct node));
    while (pr->next && pr->next->x < p)
    {
        pr = pr->next;
    }
    node->next = pr->next;
    node->x = p;
    pr->next = node;

}

错误是在这个插入函数里面吗?把你报错的截图贴上来