Skip to content

Commit

Permalink
Fix serious vulnerabilities. It is now running normally.
Browse files Browse the repository at this point in the history
  • Loading branch information
ax-6 committed Feb 20, 2024
1 parent 29c5e03 commit 45e20c7
Showing 1 changed file with 20 additions and 21 deletions.
41 changes: 20 additions & 21 deletions compiler/lexer/lexer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -357,26 +357,26 @@ int Compiler::Lexer::LexToken(Token& return_token) {
buffer_ptr_ = read_ptr;

// Handle the detailed information of tokens.
Token::ValueStr value;
value.location = location;
value.length = length;
switch (return_token.type) {
case Token::Type::IDENTIFIER:
return_token.type = Token::Type::KEYWORD;
return_token.value.keyword =
token_map_.GetKeywordValue(std::string(location, length));
if (return_token.value.keyword == Token::KeywordType::NONE) {
return_token.value.identifier.location = location;
return_token.value.identifier.length = length;
return_token.value.identifier = value;
break;
}
return_token.type = Token::Type::KEYWORD;
break;

case Token::Type::CHARACTER:
return_token.value.character.location = location;
return_token.value.character.length = length;
return_token.value.character = value;
break;

case Token::Type::STRING:
return_token.value.string.location = location;
return_token.value.string.length = length;
return_token.value.string = value;
break;

case Token::Type::OPERATOR:
Expand All @@ -388,22 +388,21 @@ int Compiler::Lexer::LexToken(Token& return_token) {
buffer_ptr_--;
return_token.value._operator =
token_map_.GetOperatorValue(std::string(location, length));
break;
}
break;

case Token::Type::NUMBER:
return_token.value.number.location = location;
return_token.value.number.length = length;
break;
case Token::Type::NUMBER:
return_token.value.number = value;
break;

default:
Debugger error_info(Debugger::Level::ERROR,
"Aq::Compiler::Lexer::LexToken",
"Lextoken_UnexpectedSituations",
"Encountered a situation where the token value "
"should not exist while processing.",
nullptr);
return -1;
}
default:
Debugger error_info(Debugger::Level::ERROR,
"Aq::Compiler::Lexer::LexToken",
"Lextoken_UnexpectedSituations",
"Encountered a situation where the token value "
"should not exist while processing.",
nullptr);
return -1;
}
}
return 0;
Expand Down

0 comments on commit 45e20c7

Please sign in to comment.