C++: fix various bugs related to different section types

backup
Christian Seiler 2 weeks ago
parent 5a633ed791
commit 8557f7a401
  1. 4
      cpp/src/monoformat_parseonly.cpp
  2. 4
      cpp/src/monoformat_structured.cpp

@ -80,14 +80,14 @@ static std::expected<TimeBasedDrawnSectionMetaData, ParseError> parseTimeBasedDr
if (!type) {
return std::unexpected(type.error());
}
if (*type != static_cast<std::uint8_t>(SectionType::AlwaysDrawn)) {
if (*type != static_cast<std::uint8_t>(SectionType::TimeBasedDrawn)) {
return std::unexpected(ParseError::InvalidValue);
}
auto size = readU24LE(data);
if (!size) {
return std::unexpected(size.error());
}
if (*size < 8) {
if (*size < 24) {
return std::unexpected(ParseError::InvalidValue);
}
auto flags = readU16LE(data);

@ -2137,7 +2137,7 @@ std::uint32_t TimeBasedDrawnSection::minimumFormatVersion() const {
std::size_t TimeBasedDrawnSection::serializeTo(std::span<std::byte> target, std::uint32_t formatVersion) const {
std::size_t pos = 0;
pos = writeU8LE(target, pos, static_cast<std::uint16_t>(SectionType::AlwaysDrawn));
pos = writeU8LE(target, pos, static_cast<std::uint16_t>(SectionType::TimeBasedDrawn));
// Will be replaced later
pos = writeU24LE(target, pos, 0);
std::uint16_t flags = 0;
@ -2303,7 +2303,7 @@ std::size_t CustomFontSection::serializeTo(std::span<std::byte> target, std::uin
std::ignore = formatVersion;
std::size_t pos = 0;
pos = writeU8LE(target, pos, static_cast<std::uint16_t>(SectionType::AlwaysDrawn));
pos = writeU8LE(target, pos, static_cast<std::uint16_t>(SectionType::CustomFont));
// Will be replaced later
pos = writeU24LE(target, pos, 0);
pos = writeU24LE(target, pos, m_fontData.size());

Loading…
Cancel
Save