diff options
author | Tsuda Kageyu <tsuda.kageyu@gmail.com> | 2016-02-22 23:17:17 +0900 |
---|---|---|
committer | Tsuda Kageyu <tsuda.kageyu@gmail.com> | 2016-02-22 23:17:17 +0900 |
commit | 2aea23aed258555c3671e183c1327cd485f99028 (patch) | |
tree | 8c94cefc8b2b513d8ad3eca1530a405f41f28c5c /taglib/riff | |
parent | e8ef0e0a4b462a185f612e01541519a150ee3343 (diff) |
Add some debug messages to RIFF::File, just in case.
Diffstat (limited to 'taglib/riff')
-rw-r--r-- | taglib/riff/rifffile.cpp | 33 |
1 files changed, 31 insertions, 2 deletions
diff --git a/taglib/riff/rifffile.cpp b/taglib/riff/rifffile.cpp index 4b031ae2..f9d33e10 100644 --- a/taglib/riff/rifffile.cpp +++ b/taglib/riff/rifffile.cpp @@ -100,31 +100,50 @@ unsigned int RIFF::File::chunkCount() const unsigned int RIFF::File::chunkDataSize(unsigned int i) const { + if(i >= d->chunks.size()) { + debug("RIFF::File::chunkPadding() - Index out of range. Returning 0."); + return 0; + } + return d->chunks[i].size; } unsigned int RIFF::File::chunkOffset(unsigned int i) const { + if(i >= d->chunks.size()) { + debug("RIFF::File::chunkPadding() - Index out of range. Returning 0."); + return 0; + } + return d->chunks[i].offset; } unsigned int RIFF::File::chunkPadding(unsigned int i) const { + if(i >= d->chunks.size()) { + debug("RIFF::File::chunkPadding() - Index out of range. Returning 0."); + return 0; + } + return d->chunks[i].padding; } ByteVector RIFF::File::chunkName(unsigned int i) const { - if(i >= chunkCount()) + if(i >= d->chunks.size()) { + debug("RIFF::File::chunkName() - Index out of range. Returning an empty vector."); return ByteVector(); + } return d->chunks[i].name; } ByteVector RIFF::File::chunkData(unsigned int i) { - if(i >= chunkCount()) + if(i >= d->chunks.size()) { + debug("RIFF::File::chunkData() - Index out of range. Returning an empty vector."); return ByteVector(); + } seek(d->chunks[i].offset); return readBlock(d->chunks[i].size); @@ -132,6 +151,11 @@ ByteVector RIFF::File::chunkData(unsigned int i) void RIFF::File::setChunkData(unsigned int i, const ByteVector &data) { + if(i >= d->chunks.size()) { + debug("RIFF::File::setChunkData() - Index out of range."); + return; + } + // Now update the specific chunk std::vector<Chunk>::iterator it = d->chunks.begin(); @@ -223,6 +247,11 @@ void RIFF::File::setChunkData(const ByteVector &name, const ByteVector &data, bo void RIFF::File::removeChunk(unsigned int i) { + if(i >= d->chunks.size()) { + debug("RIFF::File::removeChunk() - Index out of range."); + return; + } + std::vector<Chunk>::iterator it = d->chunks.begin(); std::advance(it, i); |