leetcode练习算法时遇到的调试bug的解决记录

指针使用越界:

1、free(): invalid next size (fast): 0x0000000001d294d0 ***

使用malloc方法动态分配指针指向的空间,实际在使用时超出了声明的空间,因此指针被污染了。出错代码如下:

    struct TreeNode*** temp=(struct TreeNode ***)malloc(sizeof(struct TreeNode**)*depth);//动态分配depth行的数组

    for(i=0;i

 

你可能感兴趣的:(C/C++)