Skip to content

Commit

Permalink
Fixed reading of FourCC as C-style string when parsing wave/wavpack f…
Browse files Browse the repository at this point in the history
…iles.
  • Loading branch information
larspalo committed Sep 5, 2024
1 parent 806155b commit 7505610
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- Option to create new panel from selection on existing panel display. (TODO)

### Fixed

- Reading of FourCC values in wave/wavpack files so that sample file details are correctly shown.

## [0.15.0] - 2024-07-27

### Added
Expand Down
10 changes: 7 additions & 3 deletions src/WAVfileParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,11 @@ bool WAVfileParser::tryParsingFile(wxString file) {
wxFFileInputStream waveFile(file);

if (waveFile.IsOk()) {
char fourCBuffer[4];
// C-style string (array of chars) with fixed size must be zero-terminated explicitly.
// This is used by .IsSameAs() when a wxString is implicitly created at the call.
// For the fourCBuffer we're thus using five elements in the array and initializing them all to zero,
// even though we'll only ever read four characters into it.
char fourCBuffer[5] = {};
unsigned uBuffer;
m_dataSize = 0;
bool dataFound = false;
Expand Down Expand Up @@ -245,7 +249,7 @@ bool WAVfileParser::tryParsingWvFile(wxString file) {
wxFFileInputStream wvFile(file);

if (wvFile.IsOk()) {
char fourCBuffer[4];
char fourCBuffer[5] = {};
unsigned uBuffer;
unsigned char uChBuffer;

Expand Down Expand Up @@ -775,7 +779,7 @@ bool WAVfileParser::parseCueChunk(wxFFileInputStream &wavFile) {

bool WAVfileParser::parseInfoListChunk(wxFFileInputStream &wavFile) {
unsigned uBuffer;
char fourCBuffer[4];
char fourCBuffer[5] = {};
unsigned char uChBuffer;

wavFile.Read(&uBuffer, 4);
Expand Down

0 comments on commit 7505610

Please sign in to comment.