Skip to content

bug: libobs/graphics: gs_matrix_scale3f crashes without a graphics context (and gs_reset_blend_state logs the wrong name) #2518

Closed

Description

@vpacher

What

  1. gs_matrix_scale3f dereferences NULL when it is called without a graphics context on the thread. The other thirteen gs_matrix_* functions check gs_valid() first, which logs "<function>: called while not in a graphics context" (at LOG_DEBUG) and returns; this one reads thread_graphics directly (top_matrix(thread_graphics)), so a plugin or a script that calls it outside a graphics context crashes OBS instead of getting the log line.
  2. gs_reset_blend_state checks with gs_valid("gs_preprocessor_name"), so its log line names the wrong function.

Both are in upstream OBS master unchanged (libobs/graphics/graphics.c); 2 is from the null/context warnings of 2015 (d242004).

Who can reach it

Plugins and scripts (gs_matrix_scale3f and gs_reset_blend_state are EXPORT, and obslua and obspython include all of graphics.h). OBS's own callers run with a graphics context.

Fix

  • gs_matrix_scale3f: if (!gs_valid("gs_matrix_scale3f")) return;, as its neighbours.
  • gs_reset_blend_state: gs_valid("gs_reset_blend_state").

Plan

One PR. RED: a cmocka test without a graphics context, with a log handler that also records LOG_DEBUG: gs_matrix_scale3f returns and logs gs_matrix_scale3f: called while not in a graphics context (now: a crash), and gs_reset_blend_state logs its own name (now: gs_preprocessor_name). GREEN: the two changes. The state stacks port (#2517) builds on the fixed C.

Activity

  1. vpacher commented on Oct 26, 2026

    @vpacher
    MemberAuthor

    Claiming: #2518

    One PR: RED (a cmocka test without a graphics context and a log handler), GREEN (the two changes).

  2. self-assigned this
    on Oct 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions