Skip to content

Instantly share code, notes, and snippets.

@GeekaholicLin
Created June 10, 2016 12:12
Show Gist options
  • Save GeekaholicLin/91987b958f993ed13be1f25c4578ac9f to your computer and use it in GitHub Desktop.
Save GeekaholicLin/91987b958f993ed13be1f25c4578ac9f to your computer and use it in GitHub Desktop.
heap corruption detected : after normal block(xxx) at 0x xxxxxxxx----新申请空间溢出的可能
if ((S.top-S.base+1)==S.stacksize)
	{
		//这里一定要基于本身的值进行申请空间,否则报错
		//heap corruption detected : after normal block(xxx) at 0x xxxxxxxx
		//典型的内存溢出错误
		//一般都是操作new申请的内存溢出
		//在初始大小上申请,肯定有溢出的可能,被自己蠢哭了
		//S.base = (SElemType*)realloc(S.base, ( STACK_INIT_SIZE+ STACKINCREMENT)*sizeof(SElemType));
		
		S.base = (SElemType*)realloc(S.base,(STACKINCREMENT+S.stacksize)*sizeof(SElemType));
		if (!S.base)
		{
			return ERROR;

		}
		S.top = S.base + S.stacksize - 1;
		S.stacksize += STACKINCREMENT;
	}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment