From e5857b7925ccf41e2f5db4afa7d88c75c5d59235 Mon Sep 17 00:00:00 2001 From: cignoni Date: Fri, 13 Jun 2008 07:05:59 +0000 Subject: [PATCH] corrected a small bug causing crashes when loading bad-formed mtl files --- wrap/io_trimesh/import_obj.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/wrap/io_trimesh/import_obj.h b/wrap/io_trimesh/import_obj.h index 7a87cafe..6fb94f94 100644 --- a/wrap/io_trimesh/import_obj.h +++ b/wrap/io_trimesh/import_obj.h @@ -210,7 +210,7 @@ static const char* ErrorMsg(int error) { "No errors", // 0 - "Material library file not found, a default white material is used", // 1 + "Material library file wrong or not found, a default white material is used", // 1 "Some materials definitions were not found, a default white material is used where no material was available", // 2 "Texture file not found", // 3 "Identical index vertices found in the same face", // 4 @@ -819,7 +819,9 @@ static bool LoadMask(const char * filename, int &mask) else first = false; //strcpy(currentMaterial.name, tokens[1].c_str()); - currentMaterial.materialName=tokens[1]; + if(tokens.size() < 2) + return false; + currentMaterial.materialName=tokens[1]; } else if (header.compare("Ka")==0) {