How to deal with bad_alloc in C++?
You can catch it like any other exception: Quite what you can usefully do from this point is up to you, but it’s definitely feasible technically.
You can catch it like any other exception: Quite what you can usefully do from this point is up to you, but it’s definitely feasible technically.
My problem turned out to be that this->meshPoints.getNormalForVertex(i) accesses an array (or vector, I can’t remember) whose length is less than this->meshPoints.getNumFaces() * 3. So it was accessing out of bounds.