LDObject::getIndex was bogus which would cause inlining to crash

Mon, 08 Apr 2013 14:53:58 +0300

author
Santeri Piippo <crimsondusk64@gmail.com>
date
Mon, 08 Apr 2013 14:53:58 +0300
changeset 74
1affec15e572
parent 73
d20867ac03cc
child 75
e95a00e34711

LDObject::getIndex was bogus which would cause inlining to crash

ldtypes.cpp file | annotate | diff | comparison | revisions
--- a/ldtypes.cpp	Mon Apr 08 14:45:28 2013 +0300
+++ b/ldtypes.cpp	Mon Apr 08 14:53:58 2013 +0300
@@ -366,9 +366,9 @@
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 // =============================================================================
 long LDObject::getIndex (OpenFile* pFile) {
-	for (LDObject* obj : pFile->objects)
-		if (obj == this)
-			return (&obj - &(pFile->objects[0]));
+	for (ulong i = 0; i < pFile->objects.size(); ++i)
+		if (pFile->objects[i] == this)
+			return i;
 	
 	return -1;
 }
\ No newline at end of file

mercurial