C语言指针问题 不知道野指针是在哪里出现的,求指点

源代码如下

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

typedef struct station{
  char name[30]; 
  int is_stop_limited; 
  int is_stop_express; 
  int is_stop_local;  
  struct station *next_station; 
} station;

void make_list(station *list, station *p){
  scanf("%s %d %d %d", list->name, &list->is_stop_limited, &list->is_stop_express, &list->is_stop_local); 
  list->next_station = NULL; 
  while(1){
    char name[30];
    int num1, num2, num3;
    scanf("%s %d %d %d", name, &num1, &num2, &num3);
    if(strcmp(name, "none")== 0){ 
      break;
    }else{
      p = (station *)malloc(sizeof(station));
      p->is_stop_limited = num1;
      p->is_stop_express = num2;
      p->is_stop_local = num3;
      strcpy(p->name, name);
      p->next_station = NULL;
      if(p == NULL){
        printf("error");
        exit(1);
      }
      for(list; list->next_station != NULL; list = list->next_station){ 
      }
      list->next_station = p;
    }
  }
}

void put_station(struct station *stations){
  for(stations; stations != NULL; stations = stations->next_station){
    printf("%s ", stations->name);
  }
  printf("\n");
}

int main(){
  struct station *stations;
  struct station *ptr;
  struct station *begin = stations;
  make_list(stations, ptr);
  put_station(begin);
  free(ptr);
  return 0;
}

在执行后输入第二串数据时make_list最后的for报出了Segmentation fault的错误,虽然感觉是出现了野指针但是不知道具体的位置,求指点

main中指针都没初始化分配空间,make_list函数就scanf住指针的变量里输入数据了。肯定不行了

您好,我是有问必答小助手,您的问题已经有小伙伴帮您解答,感谢您对有问必答的支持与关注!
PS:问答VIP年卡 【限时加赠:IT技术图书免费领】,了解详情>>> https://vip.csdn.net/askvip?utm_source=1146287632