Asan: correct some undefined, ... problems
This commit is contained in:
@@ -552,7 +552,8 @@ void cDialog::run(std::function<void(cDialog&)> onopen){
|
|||||||
win.close();
|
win.close();
|
||||||
#endif
|
#endif
|
||||||
win.create(sf::VideoMode(winRect.width(), winRect.height()), "Dialog", sf::Style::Titlebar);
|
win.create(sf::VideoMode(winRect.width(), winRect.height()), "Dialog", sf::Style::Titlebar);
|
||||||
win.setPosition({parentPos.x + int(parentSz.x - winRect.width()) / 2, parentPos.y + int(parentSz.y - winRect.height()) / 2});
|
// ASAN overflow
|
||||||
|
win.setPosition({parentPos.x + (int(parentSz.x) - winRect.width()) / 2, parentPos.y + (int(parentSz.y) - winRect.height()) / 2});
|
||||||
draw();
|
draw();
|
||||||
makeFrontWindow(parent ? parent-> win : mainPtr);
|
makeFrontWindow(parent ? parent-> win : mainPtr);
|
||||||
makeFrontWindow(win);
|
makeFrontWindow(win);
|
||||||
|
@@ -548,7 +548,8 @@ void set_up_shop_array() {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
shop_sbar->setMaximum(shop_array.size() - 8);
|
// ASAN undefined behaviour
|
||||||
|
shop_sbar->setMaximum(long(shop_array.size()) - 8);
|
||||||
}
|
}
|
||||||
|
|
||||||
void start_talk_mode(short m_num,short personality,mon_num_t monst_type,short store_face_pic) {
|
void start_talk_mode(short m_num,short personality,mon_num_t monst_type,short store_face_pic) {
|
||||||
|
@@ -701,15 +701,25 @@ void cStringRecorder::operator()(cDialog& me) {
|
|||||||
switch(type) {
|
switch(type) {
|
||||||
case NOTE_SCEN:
|
case NOTE_SCEN:
|
||||||
str1 = univ.scenario.spec_strs[label1];
|
str1 = univ.scenario.spec_strs[label1];
|
||||||
str2 = univ.scenario.spec_strs[label2];
|
if (label2>=univ.scenario.spec_strs.size())
|
||||||
|
showError("cStringRecorder(): bad label 2.");
|
||||||
|
else
|
||||||
|
str2 = univ.scenario.spec_strs[label2];
|
||||||
break;
|
break;
|
||||||
case NOTE_TOWN:
|
case NOTE_TOWN:
|
||||||
str1 = univ.town->spec_strs[label1];
|
str1 = univ.town->spec_strs[label1];
|
||||||
str2 = univ.town->spec_strs[label2];
|
if (label2>=univ.town->spec_strs.size())
|
||||||
|
showError("cStringRecorder(): bad label 2.");
|
||||||
|
else
|
||||||
|
str2 = univ.town->spec_strs[label2];
|
||||||
break;
|
break;
|
||||||
case NOTE_OUT:
|
case NOTE_OUT:
|
||||||
str1 = univ.scenario.outdoors[label1b][label2b]->spec_strs[label1];
|
str1 = univ.scenario.outdoors[label1b][label2b]->spec_strs[label1];
|
||||||
str2 = univ.scenario.outdoors[label1b][label2b]->spec_strs[label2];
|
// memory problem, ie. called with label=65535(-1)
|
||||||
|
if (label2>=univ.scenario.outdoors[label1b][label2b]->spec_strs.size())
|
||||||
|
showError("cStringRecorder(): bad label 2.");
|
||||||
|
else
|
||||||
|
str2 = univ.scenario.outdoors[label1b][label2b]->spec_strs[label2];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if(univ.party.record(type, str1, location))
|
if(univ.party.record(type, str1, location))
|
||||||
|
@@ -387,7 +387,8 @@ static void put_item_graphics(cDialog& me, size_t& first_item_shown, short& curr
|
|||||||
if(first_item_shown == 0)
|
if(first_item_shown == 0)
|
||||||
me["up"].hide();
|
me["up"].hide();
|
||||||
else me["up"].show();
|
else me["up"].show();
|
||||||
if(first_item_shown > item_array.size() - 7 ||
|
// ASAN undefined behaviour, ie. item_array.size can be less than 7
|
||||||
|
if(first_item_shown+7 > item_array.size() ||
|
||||||
item_array.size() <= 8)
|
item_array.size() <= 8)
|
||||||
me["down"].hide();
|
me["down"].hide();
|
||||||
else me["down"].show();
|
else me["down"].show();
|
||||||
|
@@ -66,6 +66,8 @@ cScenario::cScenario() {
|
|||||||
bg_fight = 4;
|
bg_fight = 4;
|
||||||
bg_town = 13;
|
bg_town = 13;
|
||||||
bg_dungeon = 9;
|
bg_dungeon = 9;
|
||||||
|
// ASAN used but unset
|
||||||
|
is_legacy = false;
|
||||||
for(short i = 0; i < town_mods.size(); i++) {
|
for(short i = 0; i < town_mods.size(); i++) {
|
||||||
town_mods[i].spec = -1;
|
town_mods[i].spec = -1;
|
||||||
}
|
}
|
||||||
|
@@ -152,7 +152,8 @@ public:
|
|||||||
size_t old_w = w, old_h = h;
|
size_t old_w = w, old_h = h;
|
||||||
w = width; h = height;
|
w = width; h = height;
|
||||||
data.resize(w * h);
|
data.resize(w * h);
|
||||||
if(old_w < width) {
|
// ASAN undefined behaviour if old_h==0, y=old_h-1 is ...
|
||||||
|
if(old_w < width && old_h) {
|
||||||
size_t dx = width - old_w;
|
size_t dx = width - old_w;
|
||||||
for(int y = old_h - 1; y > 0; y--) {
|
for(int y = old_h - 1; y > 0; y--) {
|
||||||
std::move_backward(data.begin() + old_w * y, data.begin() + old_w * (y + 1), data.begin() + w * (y + 1) - dx);
|
std::move_backward(data.begin() + old_w * y, data.begin() + old_w * (y + 1), data.begin() + w * (y + 1) - dx);
|
||||||
|
@@ -20,6 +20,8 @@ const short cCreature::charm_odds[21] = {90,90,85,80,78, 75,73,60,40,30, 20,10,4
|
|||||||
cCreature::cCreature() {
|
cCreature::cCreature() {
|
||||||
attitude = eAttitude::DOCILE;
|
attitude = eAttitude::DOCILE;
|
||||||
cur_loc.x = cur_loc.y = targ_loc.x = targ_loc.y = 80;
|
cur_loc.x = cur_loc.y = targ_loc.x = targ_loc.y = 80;
|
||||||
|
// ASAN party_summoned writed but unset
|
||||||
|
party_summoned = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
cCreature::cCreature(int num) : cCreature() {
|
cCreature::cCreature(int num) : cCreature() {
|
||||||
|
@@ -32,7 +32,8 @@ public:
|
|||||||
void clear() {dudes.clear();}
|
void clear() {dudes.clear();}
|
||||||
cCreature& operator[](size_t n);
|
cCreature& operator[](size_t n);
|
||||||
const cCreature& operator[](size_t n) const;
|
const cCreature& operator[](size_t n) const;
|
||||||
cPopulation() : which_town(200) {}
|
// ASAN hostile copied but unset
|
||||||
|
cPopulation() : which_town(200), hostile(false) {}
|
||||||
std::vector<cCreature>::iterator begin() {return dudes.begin();}
|
std::vector<cCreature>::iterator begin() {return dudes.begin();}
|
||||||
std::vector<cCreature>::iterator end() {return dudes.end();}
|
std::vector<cCreature>::iterator end() {return dudes.end();}
|
||||||
// Apparently Visual Studio needs this to work
|
// Apparently Visual Studio needs this to work
|
||||||
|
Reference in New Issue
Block a user