Skip to content
Snippets Groups Projects
Commit a8b2683b authored by Rye Mutt's avatar Rye Mutt :bread:
Browse files

Fix potential crash in animation parsing

parent d1573cb5
No related branches found
No related tags found
No related merge requests found
...@@ -2132,30 +2132,27 @@ void LLKeyframeMotion::onLoadComplete(const LLUUID& asset_uuid, ...@@ -2132,30 +2132,27 @@ void LLKeyframeMotion::onLoadComplete(const LLUUID& asset_uuid,
} }
S32 size = file.getSize(); S32 size = file.getSize();
U8* buffer = new U8[size]; std::unique_ptr<U8[]> buffer(new U8[size]);
if (!file.read((U8*)buffer, size)) /*Flawfinder: ignore*/ if (!file.read((U8*)buffer.get(), size)) /*Flawfinder: ignore*/
{ {
delete[] buffer; LL_WARNS() << "Failed to load asset for animation from cache " << motionp->getName() << ":" << motionp->getID() << LL_ENDL;
LL_WARNS() << "Failed to load asset for animation from cache " << motionp->getName() << ":" << motionp->getID() << LL_ENDL;
motionp->mAssetStatus = ASSET_FETCH_FAILED; motionp->mAssetStatus = ASSET_FETCH_FAILED;
return; return;
} }
LL_DEBUGS("Animation") << "Loading keyframe data for: " << motionp->getName() << ":" << motionp->getID() << " (" << size << " bytes)" << LL_ENDL; LL_DEBUGS("Animation") << "Loading keyframe data for: " << motionp->getName() << ":" << motionp->getID() << " (" << size << " bytes)" << LL_ENDL;
LLDataPackerBinaryBuffer dp(buffer, size); LLDataPackerBinaryBuffer dp(buffer.get(), size);
if (motionp->deserialize(dp, asset_uuid)) if (motionp->deserialize(dp, asset_uuid))
{ {
motionp->mAssetStatus = ASSET_LOADED; motionp->mAssetStatus = ASSET_LOADED;
} }
else else
{ {
delete[] buffer;
LL_WARNS() << "Failed to decode asset for animation " << motionp->getName() << ":" << motionp->getID() << LL_ENDL; LL_WARNS() << "Failed to decode asset for animation " << motionp->getName() << ":" << motionp->getID() << LL_ENDL;
motionp->mAssetStatus = ASSET_FETCH_FAILED; motionp->mAssetStatus = ASSET_FETCH_FAILED;
return;
} }
delete[] buffer;
} }
else else
{ {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment