asan: avoid some memory problems...

This commit is contained in:
Laurent Alonso(fr)
2020-05-07 20:31:37 +02:00
committed by Celtic Minstrel
parent 7aee4abe81
commit 2921b23116
3 changed files with 17 additions and 2 deletions

View File

@@ -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;