解法只在大规模数据测试下出错，有哪些可能的原因

``````1 2 5 -1
2 4 5 8 10 -1
//-1代表该链表输入结束``````
``````#include <stdio.h>
#include <stdlib.h>
struct node
{
int data;
int* next;
};
typedef struct node * List;
List MakeEmpty()
{
List L;
L = (List)malloc(sizeof(struct node));
L->data = 0;
L->next = NULL;
return L;
}
void attach(List L, int data)//头插法
{
List p;
p = (List)malloc(sizeof(struct node));
p->data = data;
p->next = L->next;
L->next = p;
}
void Build(List L)
{
int tmp;
scanf("%d", &tmp);
while (tmp != -1)
{
attach(L, tmp);
scanf("%d", &tmp);
}
}
List merge(List L1, List L2)
{
List L;
L = MakeEmpty();

while (L1 && L2)
{
if (L1->data > L2->data)
{
L1 = L1->next;
}
else if (L1->data < L2->data)
{
L2 = L2->next;
}
else
{
attach(L, L1->data);
L2 = L2->next;
}
}
return L;
}
void output(List L)
{
if (L->next == NULL)
{
printf("NULL\n");
return 0;
}
int flag = 1;
while (L->next)
{
L = L->next;
if (flag)
{
printf("%d", L->data);
flag = 0;
}
else
printf(" %d", L->data);
}
printf("\n");
}
int main()
{
List L1, L2, L;
L1 = MakeEmpty();
L2 = MakeEmpty();
Build(L1);
Build(L2);

L1 = L1->next;//L1 和 L2 有头节点
L2 = L2->next;
if (!L1 && !L2)//处理有空表的情况
{
printf("NULL\n");
return 0;
}

L = merge(L1, L2);
output(L);

return 0;
}
``````