Skip to content

Commit

Permalink
Merge pull request #13740 from acolombier/fix/sampler-clone-crash
Browse files Browse the repository at this point in the history
fix: prevent null CO access when cloning sampler or preview
  • Loading branch information
JoergAtGithub authored Oct 10, 2024
2 parents f4ace49 + be86cbb commit 34dde6f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/engine/channels/enginechannel.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class EngineChannel : public EngineObject {
void setTalkover(bool enabled);
virtual bool isTalkoverEnabled() const;
inline bool isTalkoverChannel() { return m_bIsTalkoverChannel; };
inline bool isPrimaryDeck() {
inline bool isPrimaryDeck() const {
return m_bIsPrimaryDeck;
};
int getChannelIndex() {
Expand Down
11 changes: 11 additions & 0 deletions src/engine/channels/enginedeck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include "engine/enginevumeter.h"
#include "moc_enginedeck.cpp"
#include "track/track.h"
#include "util/assert.h"
#include "util/sample.h"

#ifdef __STEM__
Expand Down Expand Up @@ -208,6 +209,16 @@ void EngineDeck::cloneStemState(const EngineDeck* deckToClone) {
VERIFY_OR_DEBUG_ASSERT(deckToClone) {
return;
}
// Sampler and preview decks don't have stem controls
if (!isPrimaryDeck() || !deckToClone->isPrimaryDeck()) {
return;
}
VERIFY_OR_DEBUG_ASSERT(m_stemGain.size() == kMaxSupportedStems &&
m_stemMute.size() == kMaxSupportedStems &&
deckToClone->m_stemGain.size() == kMaxSupportedStems &&
deckToClone->m_stemMute.size() == kMaxSupportedStems) {
return;
}
for (int stemIdx = 0; stemIdx < kMaxSupportedStems; stemIdx++) {
m_stemGain[stemIdx]->set(deckToClone->m_stemGain[stemIdx]->get());
m_stemMute[stemIdx]->set(deckToClone->m_stemMute[stemIdx]->get());
Expand Down

0 comments on commit 34dde6f

Please sign in to comment.