Skip to content

libobs, frontend: Don't crash on NULL output id - #14050

Open
samirakash248-max wants to merge 2 commits into
obsproject:masterfrom
samirakash248-max:fix-null-output-segfault
Open

samirakash248-max wants to merge 2 commits into
obsproject:masterfrom
samirakash248-max:fix-null-output-segfault

Conversation

@samirakash248-max

Copy link
Copy Markdown

Description

Adds a NULL check in find_output() within libobs/obs-output.c before comparing strings with strcmp(), and initializes output pointers to nullptr in OBSBasicSettings_Stream.cpp.

Fixes #12843

Motivation and Context

When opening Settings with a streaming service protocol that has no registered outputs or when querying supported codecs with a null output ID, find_output(id) receives a NULL pointer. Because find_output() did not validate the input ID before invoking strcmp(), it resulted in a segmentation fault.

With this change, find_output() safely returns NULL when passed a NULL pointer, and public getters return their expected not-found values instead of crashing.

How Has This Been Tested?

  • Verified that calling find_output(NULL) and related getters (obs_get_output_supported_video_codecs(NULL)) safely returns NULL without crashing.
  • Tested that valid output IDs continue to resolve correctly.
  • Verified settings initialization when protocol output lookups return no match.

Types of changes

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

Checklist:

  • I have read the contributing document.
  • My code follows the project's style guidelines.
  • My code is not on the master branch.
  • My code has been tested.
  • All commit messages are properly formatted and commits squashed where appropriate.
  • I have included updates to all appropriate documentation.

Check if id is NULL in find_output() before comparing with strcmp(),
and initialize output variables to nullptr in OBSBasicSettings_Stream.

Fixes a crash (segfault) when opening Settings with a streaming protocol
that has no registered outputs or when querying supported codecs.

Closes obsproject#12843
@notr1ch

notr1ch commented Oct 18, 2026

Copy link
Copy Markdown
Member

One could argue that passing NULL to find_output, obs_get_output_supported_video_codecs, etc. is the actual mistake. It makes no sense to pass NULL to these functions, so the code calling these is likely broken, not the functions themselves, much like how code calling strcmp with NULL is broken and not strcmp itself. Papering over logical errors by ignoring NULL makes other bugs harder to find.

@Warchamp7

Copy link
Copy Markdown
Member

Agreeing with R1CH and also curious what circumstances can lead to having a streaming protocol with no outputs.

Address review feedback by keeping libobs find_output() unchanged
and properly handling null output lookups in the frontend caller.

Check if protocol outputs are registered in FindProtocol() for SRT
and RIST, and ensure output is non-null before querying supported
codecs in OBSBasicSettings_Stream.
@samirakash248-max

Copy link
Copy Markdown
Author

Thanks for the feedback @notr1ch and @Warchamp7!

That makes total sense regarding libobs — callers shouldn't be passing NULL expecting find_output() to silently handle logical errors.

I've reverted the change in libobs/obs-output.c and resolved the issue at the call sites in frontend/settings/OBSBasicSettings_Stream.cpp:

  1. To answer @Warchamp7's question on how this occurs:
    In OBSBasicSettings::FindProtocol(), while rtmps:// checks obs_is_output_protocol_registered("RTMPS"), srt:// and rist:// were missing that registration check:
    if (obs_is_output_protocol_registered("RTMPS") && server.startsWith("rtmps://")) {
        return QString("RTMPS");
    }
    
    if (server.startsWith("srt://")) {
        return QString("SRT");
    }

@WizardCM WizardCM added the kind/bug Categorizes issue or PR as related to a bug. label Oct 30, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/bug Categorizes issue or PR as related to a bug.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Settings window crashes (segfault) the app when there are no outputs

4 participants