Skip to content

libobs pulse: get_default_id leaks the sink name when the default sink name is empty #158

Closed

Description

@zackees

Found during the sanitizer launch passes (round 2 meta issue linked as parent). Upstream OBS code, unchanged in this fork.

Bug

In get_default_id():

if (!pdo->default_sink_name || !*pdo->default_sink_name) {
    *id = bzalloc(1);              // empty-string case: pdo->default_sink_name is never freed
} else {
    ...
    bfree(pdo->default_sink_name);
}

When PulseAudio/PipeWire reports an empty default sink name, the bstrdup copy made in pulseaudio_default_devices leaks. That happens with no sinks, a headless or CI box, or a null sink being removed. devices_match() calls this from obs_source_audio_output_capture_device_changed on source creation and on every device change. Each call also does a blocking round-trip to the sound server.

It came to light while triaging the TSan pass, whose reports from this path were in uninstrumented libpulse and were dismissed as false positives.

Fix

Call bfree(pdo->default_sink_name) unconditionally (it's NULL-safe) after building *id.

Activity

  1. added
    bug
    on Oct 10, 2026
  2. zackees commented on Oct 13, 2026

    @zackees
    MemberAuthor

    Claiming: #158. Plan: free default_sink_name on both branches of get_default_id, with a cmocka test (RED first) if the pulse wrapper can be driven without a sound server; otherwise a characterization of the leak through a stubbed pulseaudio_get_server_info. One PR.

  3. added
    claimed
    on Oct 13, 2026
  4. added a commit that references this issue on Oct 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugclaimed

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions