From f7f32bd33d1a3e98e7b048c107a3d3553bb84468 Mon Sep 17 00:00:00 2001 From: John Haddon Date: Fri, 2 May 2025 11:20:57 +0100 Subject: [PATCH] Alembic MeshReader : Don't load invalid UVs If the UVs in the Alembic archive were malformed, we were creating invalid primitive variables, with incorrect data lengths. These then caused corruption when `reverseWinding()` ran off the end of the array. --- Changes | 3 +++ .../src/IECoreAlembic/MeshReader.cpp | 19 +++++++++++++++++-- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/Changes b/Changes index 47822192b6..212f23d2bd 100644 --- a/Changes +++ b/Changes @@ -1,7 +1,10 @@ 10.5.x.x (relative to 10.5.13.1) ======== +Fixes +----- +- Alembic : Fixed crashes caused by invalid UVs. 10.5.13.1 (relative to 10.5.13.0) ========= diff --git a/contrib/IECoreAlembic/src/IECoreAlembic/MeshReader.cpp b/contrib/IECoreAlembic/src/IECoreAlembic/MeshReader.cpp index 385086ab4c..b0e49ba740 100644 --- a/contrib/IECoreAlembic/src/IECoreAlembic/MeshReader.cpp +++ b/contrib/IECoreAlembic/src/IECoreAlembic/MeshReader.cpp @@ -150,8 +150,23 @@ class MeshReader : public PrimitiveReader } } - PrimitiveVariable::Interpolation interpolation = PrimitiveReader::interpolation( uvs.getScope() ); - primitive->variables["uv"] = PrimitiveVariable( interpolation, uvData, indexData ); + const PrimitiveVariable primitiveVariable( PrimitiveReader::interpolation( uvs.getScope() ), uvData, indexData ); + if( primitive->isPrimitiveVariableValid( primitiveVariable ) ) + { + primitive->variables["uv"] = primitiveVariable; + } + else + { + IECore::msg( + IECore::Msg::Warning, "PrimitiveReader::readGeomParam", + boost::format( + "Ignoring invalid \"uv\" property on object \"%1%\" (size %2%, expected %3%)" + ) + % uvs.getParent().getObject().getFullName() + % ( indexData ? indexData->readable().size() : uvData->readable().size() ) + % primitive->variableSize( primitiveVariable.interpolation ) + ); + } } };