From d0168067293a8802f61a8daf86a3071b30e1d1ed Mon Sep 17 00:00:00 2001 From: ganovelli Date: Tue, 31 Mar 2009 13:36:32 +0000 Subject: [PATCH] added case vertSize or faceSize are 0 --- wrap/io_trimesh/import_vmi.h | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/wrap/io_trimesh/import_vmi.h b/wrap/io_trimesh/import_vmi.h index 6883e6c5..a22a3717 100644 --- a/wrap/io_trimesh/import_vmi.h +++ b/wrap/io_trimesh/import_vmi.h @@ -130,15 +130,18 @@ namespace io { /* resize the vector of vertices */ m.vert.resize(vertSize); - int read; + int read = 0; /* load the vertices */ - read=fread((void*)& m.vert[0],sizeof(VertexType),vertSize,f); + if(vertSize>0) + read=fread((void*)& m.vert[0],sizeof(VertexType),vertSize,f); assert(ferror(f)==0); assert(read==vertSize); + read = 0; m.face.resize(faceSize); - /* load the faces */ - read = fread((void*)& m.face[0],sizeof(FaceType),faceSize,f); + if(faceSize>0) + /* load the faces */ + read = fread((void*)& m.face[0],sizeof(FaceType),faceSize,f); assert(ferror(f)==0); assert(!feof(f)); assert(read==faceSize);