Mercurial > hg > openttd
changeset 19983:6e9ec9aed82d draft
(svn r24915) -Fix: Several out-of-bounds reads
author | smatz <smatz@openttd.org> |
---|---|
date | Mon, 14 Jan 2013 21:16:56 +0000 |
parents | 404316725130 |
children | 9bbc417e1a2a |
files | src/cargotype.h src/highscore_gui.cpp src/strings.cpp src/widget.cpp |
diffstat | 4 files changed, 9 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/src/cargotype.h +++ b/src/cargotype.h @@ -163,13 +163,13 @@ * @param var Reference getting the cargospec. * @see CargoSpec */ -#define FOR_ALL_SORTED_CARGOSPECS(var) for (uint8 index = 0; var = _sorted_cargo_specs[index], index < _sorted_cargo_specs_size; index++) +#define FOR_ALL_SORTED_CARGOSPECS(var) for (uint8 index = 0; index < _sorted_cargo_specs_size && (var = _sorted_cargo_specs[index], true) ; index++) /** * Loop header for iterating over 'real' cargoes, sorted by name. Phony cargoes like regearing cargoes are skipped. * @param var Reference getting the cargospec. * @see CargoSpec */ -#define FOR_ALL_SORTED_STANDARD_CARGOSPECS(var) for (uint8 index = 0; var = _sorted_cargo_specs[index], index < _sorted_standard_cargo_specs_size; index++) +#define FOR_ALL_SORTED_STANDARD_CARGOSPECS(var) for (uint8 index = 0; index < _sorted_standard_cargo_specs_size && (var = _sorted_cargo_specs[index], true); index++) #endif /* CARGOTYPE_H */
--- a/src/highscore_gui.cpp +++ b/src/highscore_gui.cpp @@ -200,7 +200,7 @@ }; static const NWidgetPart _nested_highscore_widgets[] = { - NWidget(WWT_PANEL, COLOUR_END, WID_H_BACKGROUND), SetMinimalSize(641, 481), SetResize(1, 1), EndContainer(), + NWidget(WWT_PANEL, COLOUR_BROWN, WID_H_BACKGROUND), SetMinimalSize(641, 481), SetResize(1, 1), EndContainer(), }; static const WindowDesc _highscore_desc(
--- a/src/strings.cpp +++ b/src/strings.cpp @@ -2063,12 +2063,12 @@ { if (this->i >= TAB_COUNT) return NULL; - const char *ret = _langpack_offs[_langtab_start[i] + j]; + const char *ret = _langpack_offs[_langtab_start[this->i] + this->j]; this->j++; - while (this->j >= _langtab_num[this->i] && this->i < TAB_COUNT) { - i++; - j = 0; + while (this->i < TAB_COUNT && this->j >= _langtab_num[this->i]) { + this->i++; + this->j = 0; } return ret;
--- a/src/widget.cpp +++ b/src/widget.cpp @@ -175,6 +175,8 @@ */ void DrawFrameRect(int left, int top, int right, int bottom, Colours colour, FrameFlags flags) { + assert(colour < COLOUR_END); + uint dark = _colour_gradient[colour][3]; uint medium_dark = _colour_gradient[colour][5]; uint medium_light = _colour_gradient[colour][6];