Skip to content

Commit 03a0e6d

Browse files
authored
Merge pull request #1214 from carstene1ns/fix_0.5.2
Fix flawed conditionals
2 parents bf602e0 + bc2d946 commit 03a0e6d

File tree

4 files changed

+7
-7
lines changed

4 files changed

+7
-7
lines changed

src/audio_decoder.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ const char wma_magic[] = { (char)0x30, (char)0x26, (char)0xB2, (char)0x75 };
130130

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

@@ -176,7 +176,7 @@ std::unique_ptr<AudioDecoder> AudioDecoder::Create(FILE* file, const std::string
176176
if (!strncmp(magic, "OggS", 4)) { // OGG
177177
#ifdef HAVE_OPUS
178178
fseek(file, 28, SEEK_SET);
179-
if (fread(magic, 4, 1, file) != 4)
179+
if (fread(magic, 4, 1, file) != 1)
180180
return nullptr;
181181
fseek(file, 0, SEEK_SET);
182182
if (!strncmp(magic, "Opus", 4)) {
@@ -190,7 +190,7 @@ std::unique_ptr<AudioDecoder> AudioDecoder::Create(FILE* file, const std::string
190190

191191
#if defined(HAVE_TREMOR) || defined(HAVE_OGGVORBIS)
192192
fseek(file, 29, SEEK_SET);
193-
if (fread(magic, 4, 1, file) != 4)
193+
if (fread(magic, 4, 1, file) != 1)
194194
return nullptr;
195195
fseek(file, 0, SEEK_SET);
196196

@@ -209,7 +209,7 @@ std::unique_ptr<AudioDecoder> AudioDecoder::Create(FILE* file, const std::string
209209
if (!strncmp(magic, "RIFF", 4)) {
210210
fseek(file, 20, SEEK_SET);
211211
uint16_t raw_enc;
212-
if (fread(&raw_enc, 2, 1, file) != 2)
212+
if (fread(&raw_enc, 2, 1, file) != 1)
213213
return nullptr;
214214
Utils::SwapByteOrder(raw_enc);
215215
fseek(file, 0, SEEK_SET);

src/audio_generic.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ void GenericAudio::Decode(uint8_t* output_buffer, int buffer_length) {
228228
float total_volume = 0;
229229
int samples_per_frame = buffer_length / output_format.channels / 2;
230230

231-
assert(buffer_length < 0);
231+
assert(buffer_length > 0);
232232

233233
if (sample_buffer.size() != (size_t)buffer_length) {
234234
sample_buffer.resize(buffer_length);

src/audio_sdl_mixer.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ void SdlMixerAudio::BGM_Play(std::string const& file, int volume, int pitch, int
288288
Output::Warning("Music not readable: %s", FileFinder::GetPathInsideGamePath(file).c_str());
289289
return;
290290
}
291-
if (fread(magic, 4, 1, filehandle) != 4)
291+
if (fread(magic, 4, 1, filehandle) != 1)
292292
return;
293293
fseek(filehandle, 0, SEEK_SET);
294294
if (!strncmp(magic, "MThd", 4)) {

src/decoder_fmmidi.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ bool FmMidiDecoder::Open(FILE* file) {
5757
fseek(file, 0, SEEK_END);
5858
file_buffer.resize(ftell(file) - old_pos);
5959
fseek(file, old_pos, SEEK_SET);
60-
size_t bytes_read = fread(file_buffer.data(), file_buffer.size(), 1, file);
60+
size_t bytes_read = fread(file_buffer.data(), 1, file_buffer.size(), file);
6161

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

0 commit comments

Comments
 (0)