Skip to content

libobs: More functions dereference the main canvas mix before video is set up #2253

Closed

Description

@rdoupe

Bug

Several libobs functions dereference obs->data.main_canvas->mix without checking it. mix is NULL until obs_reset_video(), so each of these crashes when called before video is set up. It's the same pattern as #2237 (obs_get_video, fixed in #2252):

  • obs_get_main_texture (libobs/obs.c.h, about line 2290)
  • obs_add_raw_video_callback2 and obs_remove_raw_video_callback (about lines 3218 and 3224). A plugin is the most likely to call these early.
  • obs_nv12_tex_active and obs_p010_tex_active (about lines 3379 and 3385)
  • get_scene_dimensions (libobs/obs-scene.c.h:265)

Only a plugin, script or headless tool that calls these before video setup can hit it. The frontend resets video first. Upstream has the same code. Found while fixing #2237.

Plan

  1. RED: a forked-child cmocka test per function, called after obs_startup() and before obs_reset_video(), expecting no crash.

  2. GREEN: each function checks main_canvas and mix first and returns its "no video" value:

    • obs_get_main_texture: NULL;
    • the raw video callback add: refused with a warning;
    • the raw video callback remove: a no-op;
    • the *_tex_active functions: false;
    • get_scene_dimensions: 0×0, as before video exists.

    Every call after video setup is unchanged.

Activity

  1. rdoupe commented on Oct 24, 2026

    @rdoupe
    CollaboratorAuthor

    Claiming: #2253.

  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