Skip to content

Commit

Permalink
Merge pull request #1214 from carstene1ns/fix_0.5.2
Browse files Browse the repository at this point in the history
Fix flawed conditionals
  • Loading branch information
Ghabry authored Jun 28, 2017
2 parents bf602e0 + bc2d946 commit 03a0e6d
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
8 changes: 4 additions & 4 deletions src/audio_decoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ const char wma_magic[] = { (char)0x30, (char)0x26, (char)0xB2, (char)0x75 };

std::unique_ptr<AudioDecoder> AudioDecoder::Create(FILE* file, const std::string& filename) {
char magic[4] = { 0 };
if (fread(magic, 4, 1, file) != 4)
if (fread(magic, 4, 1, file) != 1)
return nullptr;
fseek(file, 0, SEEK_SET);

Expand Down Expand Up @@ -176,7 +176,7 @@ std::unique_ptr<AudioDecoder> AudioDecoder::Create(FILE* file, const std::string
if (!strncmp(magic, "OggS", 4)) { // OGG
#ifdef HAVE_OPUS
fseek(file, 28, SEEK_SET);
if (fread(magic, 4, 1, file) != 4)
if (fread(magic, 4, 1, file) != 1)
return nullptr;
fseek(file, 0, SEEK_SET);
if (!strncmp(magic, "Opus", 4)) {
Expand All @@ -190,7 +190,7 @@ std::unique_ptr<AudioDecoder> AudioDecoder::Create(FILE* file, const std::string

#if defined(HAVE_TREMOR) || defined(HAVE_OGGVORBIS)
fseek(file, 29, SEEK_SET);
if (fread(magic, 4, 1, file) != 4)
if (fread(magic, 4, 1, file) != 1)
return nullptr;
fseek(file, 0, SEEK_SET);

Expand All @@ -209,7 +209,7 @@ std::unique_ptr<AudioDecoder> AudioDecoder::Create(FILE* file, const std::string
if (!strncmp(magic, "RIFF", 4)) {
fseek(file, 20, SEEK_SET);
uint16_t raw_enc;
if (fread(&raw_enc, 2, 1, file) != 2)
if (fread(&raw_enc, 2, 1, file) != 1)
return nullptr;
Utils::SwapByteOrder(raw_enc);
fseek(file, 0, SEEK_SET);
Expand Down
2 changes: 1 addition & 1 deletion src/audio_generic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ void GenericAudio::Decode(uint8_t* output_buffer, int buffer_length) {
float total_volume = 0;
int samples_per_frame = buffer_length / output_format.channels / 2;

assert(buffer_length < 0);
assert(buffer_length > 0);

if (sample_buffer.size() != (size_t)buffer_length) {
sample_buffer.resize(buffer_length);
Expand Down
2 changes: 1 addition & 1 deletion src/audio_sdl_mixer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ void SdlMixerAudio::BGM_Play(std::string const& file, int volume, int pitch, int
Output::Warning("Music not readable: %s", FileFinder::GetPathInsideGamePath(file).c_str());
return;
}
if (fread(magic, 4, 1, filehandle) != 4)
if (fread(magic, 4, 1, filehandle) != 1)
return;
fseek(filehandle, 0, SEEK_SET);
if (!strncmp(magic, "MThd", 4)) {
Expand Down
2 changes: 1 addition & 1 deletion src/decoder_fmmidi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ bool FmMidiDecoder::Open(FILE* file) {
fseek(file, 0, SEEK_END);
file_buffer.resize(ftell(file) - old_pos);
fseek(file, old_pos, SEEK_SET);
size_t bytes_read = fread(file_buffer.data(), file_buffer.size(), 1, file);
size_t bytes_read = fread(file_buffer.data(), 1, file_buffer.size(), file);

if ((bytes_read != file_buffer.size()) || (!seq->load(this, read_func))) {
error_message = "FM Midi: Error reading file";
Expand Down

0 comments on commit 03a0e6d

Please sign in to comment.