Avoid a null deref in sound output

This commit is contained in:
Jason Flatt 2022-10-18 13:04:36 -07:00
parent e40d93c007
commit dd609a8a62
2 changed files with 30 additions and 0 deletions

View file

@ -81,3 +81,5 @@ modules:
path: mame.ini path: mame.ini
- type: patch - type: patch
path: floppy.patch path: floppy.patch
- type: patch
path: sound.patch

28
sound.patch Normal file
View file

@ -0,0 +1,28 @@
diff --git a/src/emu/sound.cpp b/src/emu/sound.cpp
index a0293063..c4989abb 100644
--- a/src/emu/sound.cpp
+++ b/src/emu/sound.cpp
@@ -761,6 +761,9 @@ read_stream_view sound_stream::update_view(attotime start, attotime end, u32 out
}
g_profiler.stop();
+ if (!m_output_view[outputnum].valid())
+ m_output_view[outputnum] = empty_view(start, end);
+
// return the requested view
return read_stream_view(m_output_view[outputnum], start);
}
diff --git a/src/emu/sound.h b/src/emu/sound.h
index 15f6a574..bfa45c45 100644
--- a/src/emu/sound.h
+++ b/src/emu/sound.h
@@ -284,6 +284,9 @@ public:
return *this;
}
+ // check basic constraints
+ bool valid() const { return m_buffer != nullptr; }
+
// return the local gain
sample_t gain() const { return m_gain; }