Skip to content

libobs: Canvases accept the internal REMOVED flag and unknown bits; leak when context init fails #2141

Closed

Description

@rdoupe

Bugs

There are two small bugs in canvas creation and load (libobs/obs-canvas.c.h).

1. Internal and unknown flag bits are accepted from callers and scene collections

obs_load_canvas() reads "flags" from the scene collection, and obs_canvas_create()/obs_canvas_create_private() take flags from the caller. All three clear only MAIN. So:

  • The internal REMOVED bit (1 << 31) is accepted. The canvas then reports obs_canvas_removed() from the start, and obs_canvas_remove() returns early, so it is never properly removed.
  • Unknown bits are stored, and they are saved back on the next save.

Only ACTIVATE, MIX_AUDIO, SCENE_REF and EPHEMERAL are public (enum obs_canvas_flags, without MAIN).

2. A canvas leaks when its context fails to initialize

obs_canvas_create_internal() returns NULL without freeing the canvas when obs_context_data_init() fails. The two later failure paths free it.

Neither bug is reachable through the frontend, which writes only valid flags. A plugin, a script or an edited scene collection can trigger them. Upstream has the same code. Found while scoping round 6 of the Rust port (R6-4).

Plan

  1. RED: real-libobs tests.
    • Load a canvas whose saved flags include REMOVED and unknown bits. Check obs_canvas_get_flags(), obs_canvas_removed(), that obs_canvas_remove() works, and the saved flags.
    • Make the same checks through obs_canvas_create() and obs_canvas_create_private().
    • Every valid flag combination is unchanged.
    • If a context init failure can be forced, run the leak path under ASan.
  2. GREEN:
    • Keep only the public flags in obs_canvas_create(), obs_canvas_create_private() and obs_load_canvas(). The main canvas keeps MAIN.
    • bfree(canvas) on the context-init failure path.
    • Every canvas OBS writes behaves as before.

Activity

  1. rdoupe commented on Oct 24, 2026

    @rdoupe
    CollaboratorAuthor

    Claiming: #2141.

  2. added
    claimed
    on Oct 24, 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

    claimed

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions