malloc gives the same memory to two different nodes. How to deal with it?

When allocating memory for two different nodes, the resulting memory are the same. Clearly, this will lead to a mistake. This happened in a function. And the process must be in a function.

(gdb) p tree->list[9]
$43 = (node *) 0x8be4180
(gdb) p tree->list[10]
$44 = (node *) 0x8be4180

At the beginning, it is correct. list[0] to list[8] is allocated properly. But it can not work well in list[9]

I very much doubt if malloc() is the problem. If you show us your code, somebody here can probably figure out what is going on.

You are right. I check the code and finally find that the error is from an assignment. but it is still strange.

list[size-2]->left = list[size-1];

the result is: list[size-2] = list[size-1];

As said before, correct before list[8] and wrong from list[9], ->left seems not to exist