]> git.xonotic.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)
committerRudolf Polzer <divverent@alientrap.org>
Fri, 1 Oct 2010 05:02:04 +0000 (07:02 +0200)
invalid

git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@10508 d7cf8633-e32d-0410-b094-e92efae38249
::stable-branch::merge=efe66e1a99b2ad1b6aaa2a5c131237b9cb7b4ee4

model_brush.c

index 471eecedede13cf405b380c7f3a52b2de1707232..a1cdb1804f824c96508a512b57c723b5c0747ccc 100644 (file)
@@ -7382,9 +7382,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);