Skip to content

Commit d578f3d

Browse files
committed
Issue #323: cannot open old calchart files when they have images.
Looks like it wasn't parsing the background images correctly. Adding test show file.
1 parent ddb0ac6 commit d578f3d

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

shows/Elements Show FINAL.shw

15 MB
Binary file not shown.

src/core/cc_sheet.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -404,14 +404,15 @@ Sheet::Sheet(size_t numPoints, const uint8_t* ptr, size_t size, ParseErrorHandle
404404
sheet->mPrintableContinuity = Print_continuity(print_name, print_cont);
405405
};
406406
auto parse_INGL_BACK = [](Sheet* sheet, const uint8_t* ptr, size_t size) {
407+
auto end_ptr = ptr + size;
407408
auto num = get_big_long(ptr);
408409
ptr += 4;
409-
if ((num + 4) != size) {
410-
throw CC_FileException("Bad Background chunk", INGL_BACK);
411-
}
412410
while (num--) {
413411
sheet->mBackgroundImages.emplace_back(ptr);
414412
}
413+
if (ptr != end_ptr) {
414+
throw CC_FileException("Bad Background chunk", INGL_BACK);
415+
}
415416
};
416417

417418
const std::map<uint32_t, std::function<void(Sheet*, const uint8_t*, size_t)>>
@@ -506,7 +507,7 @@ std::vector<uint8_t> Sheet::SerializeSheetData() const
506507
Parser::Construct_block(
507508
INGL_PCNT, SerializePrintContinuityData()));
508509

509-
// Write Continuity
510+
// Write Background
510511
Parser::Append(result, Parser::Construct_block(INGL_BACK, SerializeBackgroundImageData()));
511512

512513
return result;

0 commit comments

Comments
 (0)