Skip to content

Commit d7fdefe

Browse files
committed
Reorder null check before dereference in Audio EndFrame
1 parent c33f9c5 commit d7fdefe

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

src/audio.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,10 @@ void Audio::Reset(bool is_lynx2)
7171

7272
void Audio::EndFrame(s16* sample_buffer, int* sample_count)
7373
{
74-
*sample_count = 0;
74+
m_frame_samples = m_buffer_pos;
7575

7676
if (IsValidPointer(sample_buffer) && IsValidPointer(sample_count))
7777
{
78-
m_frame_samples = m_buffer_pos;
7978
*sample_count = m_frame_samples;
8079

8180
for (u32 i = 0; i + 1 < m_frame_samples; i += 2)
@@ -115,7 +114,7 @@ void Audio::EndFrame(s16* sample_buffer, int* sample_count)
115114

116115
#ifndef GLYNX_DISABLE_VGMRECORDER
117116
if (m_vgm_recording_enabled)
118-
m_vgm_recorder.UpdateTiming(*sample_count / 2);
117+
m_vgm_recorder.UpdateTiming(m_frame_samples / 2);
119118
#endif
120119

121120
m_buffer_pos = 0;

0 commit comments

Comments
 (0)