RemoveRedundantMaterials: Fix crash bug when unreferenced materials are removed.

Commit message explains it in good detail. Crash was detected with `test\models-nonbsd\OBJ\rifle.obj` that created one unreferenced material and one referenced one.

`RemoveRedundantMaterials.cpp` has not been touched in 2 years. I suspect this bug surfaced instead when OBJ importer started importing materials that were not referenced by any mesh. I have no idea when this happened.

Even if this code was not touched in many years, it had a very clear bug. Fixes #269.