Skip to content

Commit 30fac51

Browse files
committed
Prevent nullptr samples from being read
Signed-off-by: Isaac Marovitz <isaacryu@icloud.com>
1 parent 4991a34 commit 30fac51

1 file changed

Lines changed: 9 additions & 6 deletions

File tree

MarathonRecomp/apu/xma_decoder.cpp

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
// Almsot all decoding code is from Xenia Canary, so leave the copyright here
1+
// Almost all decoding code is from Xenia Canary, so leave the copyright here
2+
23
/**
34
******************************************************************************
45
* Xenia : Xbox 360 Emulator Research Project *
@@ -353,12 +354,14 @@ void Decode(XmaPlayback *playback) {
353354
// Select the appropriate array based on the current channel.
354355
auto in = reinterpret_cast<const float *>(samples[j]);
355356

356-
// Raw samples sometimes aren't within [-1, 1]
357-
float scaled_sample = clamp_float(in[i], -1.0f, 1.0f) * scale;
357+
if (in != nullptr) {
358+
// Raw samples sometimes aren't within [-1, 1]
359+
float scaled_sample = clamp_float(in[i], -1.0f, 1.0f) * scale;
358360

359-
// Convert the sample and output it in big endian.
360-
auto sample = static_cast<int16_t>(scaled_sample);
361-
out[o++] = ByteSwap(sample);
361+
// Convert the sample and output it in big endian.
362+
auto sample = static_cast<int16_t>(scaled_sample);
363+
out[o++] = ByteSwap(sample);
364+
}
362365
}
363366
}
364367
}

0 commit comments

Comments
 (0)