Heap corruption detected

This is a discussion on Heap corruption detected within the C++ Programming forums, part of the General Programming Boards category; I don't know what I am doing, but I would like someone to help me on this. I am trying ...

  1. #1
    Registered User
    Join Date
    May 2010
    Posts
    5

    Heap corruption detected

    I don't know what I am doing, but I would like someone to help me on this.

    I am trying to build a default constructor by using the initializer list, and I am getting this error.

    HEAP CORRUPTION DETECTED: after Normal block(#126) at 0x003C5060. CRT detected that the application wrote to memory after end of heap buffer.

    I believe the error could be on these following modules.

    Code:
    class list
    {
    public:
    ... ...
    
    private:
    	struct node
    	{
    		// constructor
    		node(const winery& winery);
    		
    		winery item;
    		node * nextByName;
    		node * nextByRating;
    	};
    
    	node * headByName;
    	node * headByRating;
    Code:
    //constructor
    
    list::list() :
    headByName(NULL),
    headByRating(NULL),
    myHead(NULL),
    myTraverser(NULL)
    
    {
    }
    
    //destructor
    
    list::~list()
    {
    	delete headByName;
    	headByName = NULL;
    	delete headByRating;
    	headByRating = NULL;
    	delete myHead;
    	myHead = NULL;
    	delete myTraverser;
    	myTraverser = NULL;
    
    }
    But I'd rather send you guys the entire code so that I can avoid any confusions, and for you to test it and know what I'm talking about.

    lab1.zip - File Shared from Box.net - Free Online File Storage

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,447
    Look at the number in () - #126

    Now read this
    How to use _crtBreakAlloc to debug a memory allocation

    This will stop in the debugger just as you allocate that block. You can then follow it through to see where you're overwriting the end of it.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Heap Corruption Detected -- Malloc issues
    By gp364481 in forum C Programming
    Replies: 4
    Last Post: 04-09-2010, 11:47 AM
  2. Heap corruption Detected Error
    By mrsirpoopsalot in forum C++ Programming
    Replies: 2
    Last Post: 10-26-2009, 03:59 PM
  3. Heap corruption detected. What does it mean?
    By franziss in forum C++ Programming
    Replies: 17
    Last Post: 07-23-2008, 02:50 AM
  4. Heap corruption errors
    By VirtualAce in forum C++ Programming
    Replies: 0
    Last Post: 07-15-2006, 04:46 PM
  5. heap question
    By mackol in forum C Programming
    Replies: 1
    Last Post: 11-30-2002, 04:03 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21