asan: avoid some memory problems...
This commit is contained in:
@@ -319,6 +319,10 @@ static unsigned char applyShift(unsigned char c){
|
||||
'~', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O',
|
||||
'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '{', '|', '}', '~',
|
||||
};
|
||||
if (c<' ')
|
||||
return ' ';
|
||||
if (c>=0x7f)
|
||||
return c;
|
||||
return afterShift[c - ' '];
|
||||
}
|
||||
|
||||
@@ -331,6 +335,11 @@ static unsigned char removeShift(unsigned char c){
|
||||
'`', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o',
|
||||
'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '[', '\\',']', '`',
|
||||
};
|
||||
// ASAN: c can be called with 0 by cControl::getAttachedKeyDescription()
|
||||
if (c<' ')
|
||||
return ' ';
|
||||
if (c>=0x7f)
|
||||
return c;
|
||||
return afterUnShift[c - ' '];
|
||||
}
|
||||
|
||||
|
@@ -215,7 +215,12 @@ short combat_obscurity(short x, short y) {
|
||||
}
|
||||
|
||||
ter_num_t coord_to_ter(short x,short y) {
|
||||
return is_out() ? univ.out[x][y] : univ.town->terrain(x,y);
|
||||
if (is_out())
|
||||
return univ.out[x][y];
|
||||
// ASAN called by place_road(..., false) with (x,y)=(univ.town->max_dim,univ.town->max_dim)
|
||||
if (x<0 || y<0 || x>=univ.town->max_dim || y>=univ.town->max_dim)
|
||||
return 0;
|
||||
return univ.town->terrain(x,y);
|
||||
}
|
||||
|
||||
////
|
||||
|
@@ -979,7 +979,8 @@ void add_string_to_buf(std::string str, unsigned short indent) {
|
||||
size_t last = 0, new_last = str.find_last_not_of(' ');
|
||||
while(last < str.length() && str[last] == text_buffer[prev_pointer].line[last])
|
||||
last++;
|
||||
while(text_buffer[prev_pointer].line[--last] == ' ');
|
||||
// ASAN last can be 0
|
||||
while(last>0 && text_buffer[prev_pointer].line[--last] == ' ');
|
||||
bool is_dup = false;
|
||||
if(last == new_last) {
|
||||
size_t num_pos = 0;
|
||||
|
Reference in New Issue
Block a user