From 87b3c4adc0c25533de2786de1c49b4b65d4db319 Mon Sep 17 00:00:00 2001 From: Rye Mutt <rye@alchemyviewer.org> Date: Tue, 10 Aug 2021 08:49:50 -0400 Subject: [PATCH] Fix potential resource leak and null termination issue in LLPolyMesh --- indra/llappearance/llpolymesh.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/indra/llappearance/llpolymesh.cpp b/indra/llappearance/llpolymesh.cpp index 1c46f0a2b40..8ea78197206 100644 --- a/indra/llappearance/llpolymesh.cpp +++ b/indra/llappearance/llpolymesh.cpp @@ -280,7 +280,7 @@ BOOL LLPolyMeshSharedData::loadMesh( const std::string& fileName ) LL_ERRS() << "Filename is Empty!" << LL_ENDL; return FALSE; } - LLFILE* fp = LLFile::fopen(fileName, "rb"); /*Flawfinder: ignore*/ + LLUniqueFile fp = LLFile::fopen(fileName, "rb"); /*Flawfinder: ignore*/ if (!fp) { LL_ERRS() << "can't open: " << fileName << LL_ENDL; @@ -604,9 +604,9 @@ BOOL LLPolyMeshSharedData::loadMesh( const std::string& fileName ) // look for morph section //------------------------------------------------------------------------- char morphName[64+1]; - morphName[sizeof(morphName)-1] = '\0'; // ensure nul-termination while(fread(&morphName, sizeof(char), 64, fp) == 64) { + morphName[sizeof(morphName)-1] = '\0'; // ensure nul-termination if (!strcmp(morphName, "End Morphs")) { // we reached the end of the morphs @@ -716,7 +716,7 @@ BOOL LLPolyMeshSharedData::loadMesh( const std::string& fileName ) allocateJointNames(1); } - fclose( fp ); + fp.close(); return status; } -- GitLab