mirror of
https://github.com/BeamMP/BeamMP-Server.git
synced 2025-07-04 00:36:14 +00:00
ProcessCompositeInput: ensure we dont cause UB on memcmp
This commit is contained in:
parent
e42256dd5f
commit
b9758ddaea
@ -129,7 +129,7 @@ static std::string CompositeInput;
|
|||||||
static bool CompositeInputExpected { false };
|
static bool CompositeInputExpected { false };
|
||||||
|
|
||||||
static void ProcessCompositeInput() {
|
static void ProcessCompositeInput() {
|
||||||
if (memcmp(CompositeInput.data(), std::array<char, 2> { 91, 65 }.data(), 2) == 0) {
|
if (CompositeInput.size() == 2 && memcmp(CompositeInput.data(), std::array<char, 2> { 91, 65 }.data(), 2) == 0) {
|
||||||
// UP ARROW
|
// UP ARROW
|
||||||
if (!ConsoleHistory.empty()) {
|
if (!ConsoleHistory.empty()) {
|
||||||
if (ConsoleHistoryReadIndex != 0) {
|
if (ConsoleHistoryReadIndex != 0) {
|
||||||
@ -137,7 +137,7 @@ static void ProcessCompositeInput() {
|
|||||||
}
|
}
|
||||||
CInputBuff = ConsoleHistory.at(ConsoleHistoryReadIndex);
|
CInputBuff = ConsoleHistory.at(ConsoleHistoryReadIndex);
|
||||||
}
|
}
|
||||||
} else if (memcmp(CompositeInput.data(), std::array<char, 2> { 91, 66 }.data(), 2) == 0) {
|
} else if (CompositeInput.size() == 2 && memcmp(CompositeInput.data(), std::array<char, 2> { 91, 66 }.data(), 2) == 0) {
|
||||||
// DOWN ARROW
|
// DOWN ARROW
|
||||||
if (!ConsoleHistory.empty()) {
|
if (!ConsoleHistory.empty()) {
|
||||||
if (ConsoleHistoryReadIndex != ConsoleHistory.size() - 1) {
|
if (ConsoleHistoryReadIndex != ConsoleHistory.size() - 1) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user