mirror of
https://github.com/taglib/taglib.git
synced 2026-07-11 13:51:12 -04:00
Fix XM save path to skip sample data after sample headers (#1369)
XM saving failed for files with samples because the save logic only advanced past sample headers and did not skip the sample data, causing the next instrument to be written at the wrong position.
This commit is contained in:
@@ -457,6 +457,7 @@ bool XM::File::save()
|
||||
}
|
||||
|
||||
unsigned long sampleHeaderSize = 0;
|
||||
unsigned long sampleDataSize = 0;
|
||||
if(sampleCount > 0) {
|
||||
seek(pos + 29);
|
||||
if(instrumentHeaderSize < 33U || !readU32L(sampleHeaderSize))
|
||||
@@ -468,9 +469,12 @@ bool XM::File::save()
|
||||
for(unsigned short j = 0; j < sampleCount; ++ j) {
|
||||
if(sampleHeaderSize > 4U) {
|
||||
seek(pos);
|
||||
if(unsigned long sampleLength = 0; !readU32L(sampleLength))
|
||||
unsigned long sampleLength = 0;
|
||||
if(!readU32L(sampleLength))
|
||||
return false;
|
||||
|
||||
sampleDataSize += sampleLength;
|
||||
|
||||
if(sampleHeaderSize > 18U) {
|
||||
seek(pos + 18);
|
||||
const auto sz = std::min(sampleHeaderSize - 18, 22UL);
|
||||
@@ -482,6 +486,8 @@ bool XM::File::save()
|
||||
}
|
||||
pos += sampleHeaderSize;
|
||||
}
|
||||
|
||||
pos += sampleDataSize;
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user