这是怎么回事?有没有哥帮看看

#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<assert.h>
typedef enum{HEAD,ATOM,CHILDLIST}Elemtag;
typedef char datatype;
typedef struct GLNode{
Elemtag tag;
union {
datatype atom;
struct GLNode* hp;
};
struct GLNode* tp;
}GList;
GList InitGenList()
{
GList
gl;
gl = NULL;
return gl;

}
bool sever(char*,char*);
char CreateGenList(GList gl,char str)
{
int n = strlen(str);
char
sub = (char
)malloc(sizeof(char) * (n - 2));//保存整个广义表//
char
hsub = (char*)malloc(sizeof(char) * (n - 2));//保存表头//
assert(sub != NULL && hsub != NULL);
strncpy(sub, str + 1, n - 2);
sub[n - 2] = '\0';
if (gl == NULL)
{
gl = (GLNode*)malloc(sizeof(GLNode));
gl->tag= HEAD;
gl->hp = gl->tp = NULL;
}
GLNode* p = gl;
while (strlen(sub) !=0)
{
p = p->tp = (GLNode*)malloc(sizeof(GLNode));
assert(p != NULL);
p->hp = p->tp = NULL;
if (sever(sub, hsub))//hsub=1,sub="2,3"//
{
if (hsub[0] == '(')
{
p->tag = CHILDLIST;
CreateGenList(p->hp, hsub);
}
else
{
p->tag = ATOM;
p->atom= atoi(hsub);
}
}

}
return sub;

}
bool sever(char sub, char hsub)
{
if (sub = '\0' || strcmp(sub, "()") == 0)
{
hsub[0] = '\0';
return true;
}
int n =5;
int i = 0;
char ch = sub[0];
int k = 0;
while (i < n && (ch != ',' || k != 0))
{
if (ch == '(')
k++;
else if (ch == ')')
k--;
i++;
ch = sub[i];
}
if (i < n)
{
sub[i] = '\0';
strcpy(hsub, sub);
strcpy(sub, sub + i + 1);
}
else if (k != 0)
return false;
else
{
strcpy(hsub, sub);
sub[0] = '\0';
}
return true;
}
void ShowGenList(GList* gl)
{
GLNode* p = gl->tp;这里报错空
while (p != NULL)
{
if (p->tag == ATOM)
{
printf("%d,", p->atom);
p = p->tp;
}
else if (p->tag == CHILDLIST)
{
ShowGenList(p->hp);
}
}
}
int main()
{
char ga[] = "(1,2,3)";
char gb[] = "(1,(2,3))";
GList
gl;
gl=InitGenList();
CreateGenList(gl, ga);
ShowGenList(gl);
return 0;
}