]> git.rm.cloudns.org Git - xonotic/darkplaces.git/commitdiff
don't crash in obj loading if v, vt, or vn are NULL or the indices are
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Thu, 30 Sep 2010 20:35:12 +0000 (20:35 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Thu, 30 Sep 2010 20:35:12 +0000 (20:35 +0000)
invalid

git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@10508 d7cf8633-e32d-0410-b094-e92efae38249

model_brush.c

index 9c7c9ad4bef35651722accc151ba2e9093556f06..fc63c983900a4dc92a7f38fd4a7a845ff490a693 100644 (file)
@@ -7383,9 +7383,12 @@ void Mod_OBJ_Load(dp_model_t *mod, void *buffer, void *bufferend)
                                vcurrent.nextindex = -1;
                                vcurrent.textureindex = textureindex;
                                vcurrent.submodelindex = submodelindex;
-                               VectorCopy(v + 3*index1, vcurrent.v);
-                               Vector2Copy(vt + 2*index2, vcurrent.vt);
-                               VectorCopy(vn + 3*index3, vcurrent.vn);
+                               if (v && index1 >= 0 && index1 < numv)
+                                       VectorCopy(v + 3*index1, vcurrent.v);
+                               if (vt && index2 >= 0 && index2 < numvt)
+                                       Vector2Copy(vt + 2*index2, vcurrent.vt);
+                               if (vn && index3 >= 0 && index3 < numvn)
+                                       VectorCopy(vn + 3*index3, vcurrent.vn);
                                if (numtriangles == 0)
                                {
                                        VectorCopy(vcurrent.v, mins);