Skip to content

Commit 45ecb42

Browse files
authored
fix: avoid accessing unowned memory (#17)
1 parent da23114 commit 45ecb42

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/scanner.cc

+4-3
Original file line numberDiff line numberDiff line change
@@ -655,9 +655,10 @@ struct Scanner {
655655

656656
bool allow_comment = !(VLD[R_DQT_STR_CTN] || VLD[BR_DQT_STR_CTN] || VLD[R_SQT_STR_CTN] || VLD[BR_SQT_STR_CTN]);
657657

658-
int16_t *ind_ptr = &ind_len_stk.back();
659-
int16_t cur_ind = *ind_ptr--;
660-
int16_t prt_ind = *ind_ptr;
658+
vector<int16_t>::reverse_iterator ind_ptr = ind_len_stk.rbegin();
659+
vector<int16_t>::reverse_iterator ind_end = ind_len_stk.rend();
660+
int16_t cur_ind = *ind_ptr++;
661+
int16_t prt_ind = ind_ptr == ind_end ? -1 : *ind_ptr;
661662
int16_t cur_ind_typ = ind_typ_stk.back();
662663

663664
bool has_tab_ind = false;

0 commit comments

Comments
 (0)