From bf14c7034d69850981f03fa2da4566c5a16c64c4 Mon Sep 17 00:00:00 2001 From: --global Date: Tue, 3 May 2022 09:32:58 +0200 Subject: [PATCH] Revert "Fix conditional jumps based on uninitialized memory at 'process_cmnt_type_1'" This reverts commit 14fd17a4911908d6a2147bbb7caf949b068200be. --- lib/c_tokenizer.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/lib/c_tokenizer.cpp b/lib/c_tokenizer.cpp index 7ccadf277..458bace9f 100644 --- a/lib/c_tokenizer.cpp +++ b/lib/c_tokenizer.cpp @@ -1241,6 +1241,7 @@ enum p_st process_cmnt_type_1(options* opts, shared_st* shared_st, cmnt_type_1_s shared_st->res_cur_pos += copy_length; + // TODO: Check if the copy can be prevented as in the outer check for non-cmd comments // The extra space is due to the removal of '*/', this is relevant because the // comment can be in the middle of the query. if (*(shared_st->res_cur_pos - 1 ) != ' ' && shared_st->res_cur_pos != res_final_pos) { @@ -1254,6 +1255,20 @@ enum p_st process_cmnt_type_1(options* opts, shared_st* shared_st, cmnt_type_1_s c_t_1_st->cur_cmd_cmnt_len = 0; } + // TODO: Related to previous TODO. Remember this is a relatively new change in the current code + // not at the beginning and previous char is not ' ' + if ( + shared_st->res_init_pos != shared_st->res_cur_pos && shared_st->res_cur_pos != res_final_pos && + *shared_st->res_cur_pos != ' ' && *(shared_st->res_cur_pos-1) != ' ' + ) { + *shared_st->res_cur_pos++ = ' '; + } else if ( + shared_st->res_init_pos != shared_st->res_cur_pos && shared_st->res_cur_pos != res_final_pos && + *shared_st->res_cur_pos == ' ' + ) { + shared_st->res_cur_pos++; + } + // if there were no space we have imposed it shared_st->prev_char = ' '; // back to main shared_st->query parsing state