[lld] r292940 - [ELF] - Fixed crash after incrementing end iterator.

George Rimar via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 24 08:07:19 PST 2017


Author: grimar
Date: Tue Jan 24 10:07:18 2017
New Revision: 292940

URL: http://llvm.org/viewvc/llvm-project?rev=292940&view=rev
Log:
[ELF] - Fixed crash after incrementing end iterator.

Next code crashed under MSVS2015 for me:
this->OutSec->Info = this->Info = 1 + It - Symbols.begin();

Because It was end() and addition of 1 is not allowed. 
vector implementation catched and failed that inside:

_Myiter& operator+=(difference_type _Off)
{	// increment by integer
 #if _ITERATOR_DEBUG_LEVEL == 2
if (this->_Getcont() == 0
	|| this->_Ptr + _Off < ((_Myvec *)this->_Getcont())->_Myfirst
	|| ((_Myvec *)this->_Getcont())->_Mylast < this->_Ptr + _Off)
   {	// report error
	_DEBUG_ERROR("vector iterator + offset out of range");
	_SCL_SECURE_OUT_OF_RANGE;

Modified:
    lld/trunk/ELF/SyntheticSections.cpp

Modified: lld/trunk/ELF/SyntheticSections.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/SyntheticSections.cpp?rev=292940&r1=292939&r2=292940&view=diff
==============================================================================
--- lld/trunk/ELF/SyntheticSections.cpp (original)
+++ lld/trunk/ELF/SyntheticSections.cpp Tue Jan 24 10:07:18 2017
@@ -1079,7 +1079,7 @@ template <class ELFT> void SymbolTableSe
         });
     // update sh_info with number of Global symbols output with computed
     // binding of STB_LOCAL
-    this->OutSec->Info = this->Info = 1 + It - Symbols.begin();
+    this->OutSec->Info = this->Info = 1 + (It - Symbols.begin());
     return;
   }
 




More information about the llvm-commits mailing list