Explorar o código

Avoid dereferencing a null pointer in the 'LoadMaterials' function in the models module (#1498)

Victor Gallet %!s(int64=4) %!d(string=hai) anos
pai
achega
03278a74bf
Modificáronse 1 ficheiros con 4 adicións e 1 borrados
  1. 4 1
      src/models.c

+ 4 - 1
src/models.c

@@ -948,7 +948,10 @@ Material *LoadMaterials(const char *fileName, int *materialCount)
 #endif
 
     // Set materials shader to default (DIFFUSE, SPECULAR, NORMAL)
-    for (unsigned int i = 0; i < count; i++) materials[i].shader = GetShaderDefault();
+    if (materials != NULL)
+    {
+        for (unsigned int i = 0; i < count; i++) materials[i].shader = GetShaderDefault();
+    }
 
     *materialCount = count;
     return materials;