Changeset - r16028:f7cfe78e8c66
[Not reviewed]
master
0 2 0
yexo - 14 years ago 2010-09-03 23:04:02
yexo@openttd.org
(svn r20731) -Fix (r20739): SmallVector did not have an assignment operator, causing invalid memory reads / double free
2 files changed with 10 insertions and 2 deletions:
0 comments (0 inline, 0 general)
src/core/smallvec_type.hpp
Show inline comments
 
@@ -36,12 +36,20 @@ protected:
 
public:
 
	SmallVector() : data(NULL), items(0), capacity(0) { }
 

	
 
	template<uint X>
 
	template <uint X>
 
	SmallVector(const SmallVector<T, X> &other) : data(NULL), items(0), capacity(0)
 
	{
 
		MemCpyT<T>(this->Append(other.Length()), other.Begin(), other.Length());
 
	}
 

	
 
	template <uint X>
 
	SmallVector &operator=(const SmallVector<T, X> &other)
 
	{
 
		this->Reset();
 
		MemCpyT<T>(this->Append(other.Length()), other.Begin(), other.Length());
 
		return *this;
 
	}
 

	
 
	~SmallVector()
 
	{
 
		free(this->data);
src/landscape.cpp
Show inline comments
 
@@ -638,7 +638,7 @@ CommandCost CmdClearArea(TileIndex tile,
 

	
 
	for (int x = sx; x <= ex; ++x) {
 
		for (int y = sy; y <= ey; ++y) {
 
			SmallVector<TileArea, 1> object_areas = _cleared_object_areas;
 
			SmallVector<TileArea, 1> object_areas(_cleared_object_areas);
 
			CommandCost ret = DoCommand(TileXY(x, y), 0, 0, flags & ~DC_EXEC, CMD_LANDSCAPE_CLEAR);
 
			_cleared_object_areas = object_areas;
 
			if (ret.Failed()) {
0 comments (0 inline, 0 general)