diff options
author | Aryadev Chavali <aryadev@aryadevchavali.com> | 2024-04-16 15:39:20 +0630 |
---|---|---|
committer | Aryadev Chavali <aryadev@aryadevchavali.com> | 2024-04-16 15:39:20 +0630 |
commit | 4b3e9b356758e133028eea278d7cb4d06c0e4d11 (patch) | |
tree | def7d59cd02c6eaf8a2c5e1385559e485f5bbd56 /asm | |
parent | 05136fdd25bf065f81ed20f74d402592a7c6e8f2 (diff) | |
download | ovm-4b3e9b356758e133028eea278d7cb4d06c0e4d11.tar.gz ovm-4b3e9b356758e133028eea278d7cb4d06c0e4d11.tar.bz2 ovm-4b3e9b356758e133028eea278d7cb4d06c0e4d11.zip |
Clear vector after deleting all tokens
Ensures that iteration over vec_out by caller doesn't occur (such as
in a loop to free the memory).
Diffstat (limited to 'asm')
-rw-r--r-- | asm/preprocesser.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/asm/preprocesser.cpp b/asm/preprocesser.cpp index d68992c..6ea6d45 100644 --- a/asm/preprocesser.cpp +++ b/asm/preprocesser.cpp @@ -37,6 +37,7 @@ pp_err_t preprocess_use_blocks(const vector<token_t *> &tokens, tokens[i + 1]->type != token_type_t::LITERAL_STRING) { VCLEAR(vec_out); + vec_out.clear(); return pp_err_t(pp_err_type_t::EXPECTED_STRING, t); } @@ -45,6 +46,7 @@ pp_err_t preprocess_use_blocks(const vector<token_t *> &tokens, if (!source) { VCLEAR(vec_out); + vec_out.clear(); return pp_err_t(pp_err_type_t::FILE_NONEXISTENT, name); } @@ -53,6 +55,7 @@ pp_err_t preprocess_use_blocks(const vector<token_t *> &tokens, if (lerr.type != lerr_type_t::OK) { VCLEAR(vec_out); + vec_out.clear(); return pp_err_t(pp_err_type_t::FILE_PARSE_ERROR, name, lerr); } @@ -120,6 +123,7 @@ pp_err_t preprocess_const_blocks(const vector<token_t *> &tokens, if (it == blocks.end()) { VCLEAR(vec_out); + vec_out.clear(); return pp_err_t(pp_err_type_t::UNKNOWN_NAME, token); } |