Stepping through malloc isn't going to help you much in this case. But most people I've met that have written a lot of C/C++ code have seen this bug at least once.
When you start asking about how much memory malloc is asking for, that's a tip-off in the wrong direction for me too; malloc handles "out of memory" pretty gracefully.
When you start asking about how much memory malloc is asking for, that's a tip-off in the wrong direction for me too; malloc handles "out of memory" pretty gracefully.