Changeset - r23026:d7c7dcc4c3c8
[Not reviewed]
master
0 9 0
Charles Pigott - 6 years ago 2018-10-14 22:36:14
charlespigott@googlemail.com
Fix: Protect against a few out of bounds or uninitialised usage errors
9 files changed with 19 insertions and 5 deletions:
0 comments (0 inline, 0 general)
src/newgrf_spritegroup.cpp
Show inline comments
 
@@ -154,6 +154,7 @@ static uint32 RotateRight(uint32 val, ui
 
{
 
	/* Do not rotate more than necessary */
 
	rot %= 32;
 
	assert(rot > 0);
 

	
 
	return (val >> rot) | (val << (32 - rot));
 
}
src/pathfinder/opf/opf_ship.cpp
Show inline comments
 
@@ -145,6 +145,7 @@ static uint FindShipTrack(const Ship *v,
 

	
 
	Track best_track = INVALID_TRACK;
 

	
 
	assert(bits != TRACK_BIT_NONE);
 
	do {
 
		Track i = RemoveFirstTrack(&bits);
 

	
 
@@ -176,7 +177,7 @@ good:;
 
		best_length = pfs.best_length;
 
bad:;
 

	
 
	} while (bits != 0);
 
	} while (bits != TRACK_BIT_NONE);
 

	
 
	*track = best_track;
 
	return best_bird_dist;
src/pathfinder/yapf/yapf_rail.cpp
Show inline comments
 
@@ -28,6 +28,8 @@ template <typename Tpf> void DumpState(T
 
	pf2.DumpBase(dmp2);
 
	FILE *f1 = fopen("yapf1.txt", "wt");
 
	FILE *f2 = fopen("yapf2.txt", "wt");
 
	assert(f1 != NULL);
 
	assert(f2 != NULL);
 
	fwrite(dmp1.m_out.Data(), 1, dmp1.m_out.Size(), f1);
 
	fwrite(dmp2.m_out.Data(), 1, dmp2.m_out.Size(), f2);
 
	fclose(f1);
src/road_map.h
Show inline comments
 
@@ -449,6 +449,7 @@ enum Roadside {
 
	ROADSIDE_GRASS            = 1, ///< Road on grass
 
	ROADSIDE_PAVED            = 2, ///< Road with paved sidewalks
 
	ROADSIDE_STREET_LIGHTS    = 3, ///< Road with street lights on paved sidewalks
 
	// 4 is unused for historical reasons
 
	ROADSIDE_TREES            = 5, ///< Road with trees on paved sidewalks
 
	ROADSIDE_GRASS_ROAD_WORKS = 6, ///< Road on grass with road works
 
	ROADSIDE_PAVED_ROAD_WORKS = 7, ///< Road with sidewalks and road works
src/settingsgen/settingsgen.cpp
Show inline comments
 
@@ -371,7 +371,10 @@ static bool CompareFiles(const char *n1,
 
	if (f2 == NULL) return false;
 

	
 
	FILE *f1 = fopen(n1, "rb");
 
	if (f1 == NULL) error("can't open %s", n1);
 
	if (f1 == NULL) {
 
		fclose(f2);
 
		error("can't open %s", n1);
 
	}
 

	
 
	size_t l1, l2;
 
	do {
src/strgen/strgen.cpp
Show inline comments
 
@@ -215,7 +215,10 @@ bool CompareFiles(const char *n1, const 
 
	if (f2 == NULL) return false;
 

	
 
	FILE *f1 = fopen(n1, "rb");
 
	if (f1 == NULL) error("can't open %s", n1);
 
	if (f1 == NULL) {
 
		fclose(f2);
 
		error("can't open %s", n1);
 
	}
 

	
 
	size_t l1, l2;
 
	do {
src/town_cmd.cpp
Show inline comments
 
@@ -719,7 +719,7 @@ void UpdateTownCargoTotal(Town *t)
 
static void UpdateTownCargoes(Town *t, TileIndex start, bool update_total = true)
 
{
 
	CargoArray accepted, produced;
 
	CargoTypes dummy;
 
	CargoTypes dummy = 0;
 

	
 
	/* Gather acceptance for all houses in an area around the start tile.
 
	 * The area is composed of the square the tile is in, extended one square in all
src/track_func.h
Show inline comments
 
@@ -61,7 +61,7 @@ static inline bool IsValidTrackdirForRoa
 
 */
 
static inline bool IsValidTrackdir(Trackdir trackdir)
 
{
 
	return (1 << trackdir & TRACKDIR_BIT_MASK) != TRACKDIR_BIT_NONE;
 
	return trackdir != INVALID_TRACKDIR && ((1 << trackdir & TRACKDIR_BIT_MASK) != TRACKDIR_BIT_NONE);
 
}
 

	
 
/**
src/window.cpp
Show inline comments
 
@@ -938,6 +938,8 @@ static void DrawOverlappedWindow(Window 
 
void DrawOverlappedWindowForAll(int left, int top, int right, int bottom)
 
{
 
	Window *w;
 

	
 
	DrawPixelInfo *old_dpi = _cur_dpi;
 
	DrawPixelInfo bk;
 
	_cur_dpi = &bk;
 

	
 
@@ -951,6 +953,7 @@ void DrawOverlappedWindowForAll(int left
 
			DrawOverlappedWindow(w, max(left, w->left), max(top, w->top), min(right, w->left + w->width), min(bottom, w->top + w->height));
 
		}
 
	}
 
	_cur_dpi = old_dpi;
 
}
 

	
 
/**
0 comments (0 inline, 0 general)