diff --git a/indra/llcharacter/llkeyframemotion.cpp b/indra/llcharacter/llkeyframemotion.cpp index 2b6002b134..cc27b9e8d2 100644 --- a/indra/llcharacter/llkeyframemotion.cpp +++ b/indra/llcharacter/llkeyframemotion.cpp @@ -44,6 +44,8 @@ #include "message.h" #include "lltimer.h" +#include // For nd::exceptions::xran + //----------------------------------------------------------------------------- // Static Definitions //----------------------------------------------------------------------------- @@ -2177,7 +2179,12 @@ void LLKeyframeMotion::onLoadComplete(LLVFS *vfs, file.read((U8*)buffer, size); /*Flawfinder: ignore*/ lldebugs << "Loading keyframe data for: " << motionp->getName() << ":" << motionp->getID() << " (" << size << " bytes)" << llendl; - + + // Handle invalid files that cannot be properly loaded + try + { + // + LLDataPackerBinaryBuffer dp(buffer, size); if (motionp->deserialize(dp)) { @@ -2188,6 +2195,17 @@ void LLKeyframeMotion::onLoadComplete(LLVFS *vfs, llwarns << "Failed to decode asset for animation " << motionp->getName() << ":" << motionp->getID() << llendl; motionp->mAssetStatus = ASSET_FETCH_FAILED; } + + // Handle invalid files that cannot be properly loaded + } + catch( nd::exceptions::xran &ex ) + { + // Maybe delete the file from the VFS here? It's corrupt, deleting it should be harmless? + + llwarns << "Failed to decode asset for animation " << motionp->getName() << ":" << motionp->getID() << " error: " << ex.what() << llendl; + motionp->mAssetStatus = ASSET_FETCH_FAILED; + } + // delete[] buffer; }