From 62486c6e7c724143b9bc92eda26393249210ff70 Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Fri, 2 Dec 2022 09:24:51 +0100 Subject: [PATCH] FIX: Fix possible division by zero - closes https://github.com/assimp/assimp/issues/4819 --- code/AssetLib/MDL/MDLLoader.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/code/AssetLib/MDL/MDLLoader.cpp b/code/AssetLib/MDL/MDLLoader.cpp index f4b4c4d26..b60657805 100644 --- a/code/AssetLib/MDL/MDLLoader.cpp +++ b/code/AssetLib/MDL/MDLLoader.cpp @@ -405,11 +405,13 @@ void MDLImporter::InternReadFile_Quake1() { } // go to the end of the skin section / the beginning of the next skin bool overflow = false; - if ((pcHeader->skinheight > INT_MAX / pcHeader->skinwidth) || (pcHeader->skinwidth > INT_MAX / pcHeader->skinheight)){ - overflow = true; - } - if (!overflow) { - szCurrent += pcHeader->skinheight * pcHeader->skinwidth +sizeof(float) * iNumImages; + if (pcHeader->skinwidth != 0 || pcHeader->skinheight != 0) { + if ((pcHeader->skinheight > INT_MAX / pcHeader->skinwidth) || (pcHeader->skinwidth > INT_MAX / pcHeader->skinheight)){ + overflow = true; + } + if (!overflow) { + szCurrent += pcHeader->skinheight * pcHeader->skinwidth +sizeof(float) * iNumImages; + } } } } else {