Skip to content

fix crash on corrupted transition name#1703

Merged
summeroff merged 2 commits into
stagingfrom
fix_transition_name_crash
May 21, 2026
Merged

fix crash on corrupted transition name#1703
summeroff merged 2 commits into
stagingfrom
fix_transition_name_crash

Conversation

@summeroff
Copy link
Copy Markdown
Contributor

Description

Net change: addSource for transitions now owns ti via unique_ptr from the start, calls try_emplace before connecting any signal handlers, and connects only if insertion actually happened — using result.first->second.get() (the map-owned pointer) as the user-data. On duplicate, the local unique_ptr destructs cleanly, no handlers ever reference a freed TransitionInfo, and a warning is logged so the situation is visible in the next dump.
Also adds a NULL-guard on obs_source_get_name — kills the std::string(nullptr) UB that was a third trigger for the same crash path.

Motivation and Context

How Has This Been Tested?

Types of changes

  • Bug fix (non-breaking change which fixes an issue)

Checklist:

  • The code has been tested.
  • All commit messages are properly formatted and commits squashed where appropriate.
  • I have included updates to all appropriate documentation.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR hardens transition tracking in CallbackManager::addSource to prevent crashes when transition names are corrupted/duplicated, by ensuring map ownership is established before signal connections and by avoiding std::string(nullptr) construction.

Changes:

  • Adds a null-guard around obs_source_get_name() for transitions before logging and key construction.
  • Reworks transition insertion to use std::unique_ptr + try_emplace, connecting signal handlers only when insertion succeeds and using the map-owned pointer as callback userdata.
  • Logs a warning when a transition with the same name is already tracked.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread obs-studio-server/source/callback-manager.cpp
@summeroff summeroff merged commit c7b1019 into staging May 21, 2026
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants