Skip to content

Commit

Permalink
rfb: ,<REPEATS> parser fix
Browse files Browse the repository at this point in the history
  • Loading branch information
mcspr committed Feb 8, 2024
1 parent 70e8f91 commit 686728a
Showing 1 changed file with 8 additions and 13 deletions.
21 changes: 8 additions & 13 deletions code/espurna/rfbridge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1025,25 +1025,20 @@ void _rfbSendFromPayload(espurna::StringView payload) {
return;
}

decltype(_rfb_repeats) repeats { _rfb_repeats };
uint8_t repeats { _rfb_repeats };

auto it = std::find(payload.begin(), payload.end(), ',');
if (it != payload.end()) {
it += 1;
if ((it == payload.end()) || (*it == '\0') || (*it == '-')) {
return;
}

const auto result = parseUnsigned(
espurna::StringView(it, payload.end()), 10);
if (!result.ok) {
return;
auto value = espurna::StringView(it + 1, payload.end());
if (value.length()) {
const auto result = parseUnsigned(value, 10);
if (result.ok) {
repeats = result.value;
}
}

repeats = result.value;
}

payload = espurna::StringView(it, payload.end());
payload = espurna::StringView(payload.begin(), it);
if (!payload.length()) {
return;
}
Expand Down

0 comments on commit 686728a

Please sign in to comment.