diff options
-rw-r--r-- | engines/sci/sfx/mixer.cpp | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/engines/sci/sfx/mixer.cpp b/engines/sci/sfx/mixer.cpp index 517d53d446..09441f9ab6 100644 --- a/engines/sci/sfx/mixer.cpp +++ b/engines/sci/sfx/mixer.cpp @@ -190,7 +190,8 @@ PCMFeedState::PCMFeedState(sfx_pcm_feed_t *f) : feed(f) { } PCMFeedState::~PCMFeedState() { - feed->destroy(feed); + if (feed) + feed->destroy(feed); free(buf); } @@ -231,6 +232,12 @@ static void mix_subscribe(sfx_pcm_mixer_t *self, sfx_pcm_feed_t *feed) { P->_feeds.push_back(fs); + // HACK: the copy of fs made in P->_feeds is a shallow copy, + // so we need to prevent fs.buf and fs.feed from being destroyed when + // fs goes out of scope + fs.buf = 0; + fs.feed = 0; + RELEASE_LOCK(); } |