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. Seems that most importers do not import unreferenced materials, which is ofc the sane way of doing it.

Even if this code was not touched in many years, it had a very clear bug. Fixes #269.