From 407854382727d793937ce0f4155d49cece1c7e1f Mon Sep 17 00:00:00 2001 From: Turo Lamminen Date: Sun, 24 Dec 2017 14:57:14 +0200 Subject: [PATCH] OpenGEX: Throw exception on malformed color4 instead of crashing --- code/OpenGEXImporter.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/code/OpenGEXImporter.cpp b/code/OpenGEXImporter.cpp index 025356c1d..5448edba5 100644 --- a/code/OpenGEXImporter.cpp +++ b/code/OpenGEXImporter.cpp @@ -778,10 +778,22 @@ static void fillColor4( aiColor4D *col4, Value *vals ) { Value *next( vals ); col4->r = next->getFloat(); next = next->m_next; + if (!next) { + throw DeadlyImportError( "OpenGEX: Not enough values to fill 4-element color, only 1" ); + } + col4->g = next->getFloat(); next = next->m_next; + if (!next) { + throw DeadlyImportError( "OpenGEX: Not enough values to fill 4-element color, only 2" ); + } + col4->b = next->getFloat(); next = next->m_next; + if (!next) { + throw DeadlyImportError( "OpenGEX: Not enough values to fill 4-element color, only 3" ); + } + col4->a = next->getFloat(); }