79270446

Date: 2024-12-11 04:15:09
Score: 0.5
Natty:
Report link

Is your heap corruption caused by a custom-made class with an array built in? The following would be an example:

class MyClass
{
    private:
    public:
    
        int* my_array = new int[10];

        ~MyClass()
        {
            delete [] my_array;
        }

        // possibly other stuff
};

If so, one can simplify the problem for debugging purposes by changing int* my_array = new int[10]; into something more like my_array[10];, then running that through debugging software. This reduces the issue to a segmentation fault rather than heap corruption, which is simpler territory to contend with. With a segmentation fault, it is easier to check if the numbers for memory sections line up.

Note: with a simple C-style array, the delete [] in the example above should be erased or commented out.

Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Contains question mark (0.5):
  • Low reputation (1):
Posted by: Ashley Ben Story