Skip to content

requesthandler: Guard NULL list item names and string values - #1355

Open
xiaoshao9704 wants to merge 1 commit into
obsproject:masterfrom
xiaoshao9704:fix/list-property-null-strings
Open

xiaoshao9704 wants to merge 1 commit into
obsproject:masterfrom
xiaoshao9704:fix/list-property-null-strings

Conversation

@xiaoshao9704

Copy link
Copy Markdown

Title: requesthandler: Guard NULL list item names and string values

Description

GetInputPropertiesListPropertyItems crashes OBS when a list property contains an item whose name (or string value) is NULL.

Utils::Obs::ArrayHelper::GetListPropertyItems assigns the raw const char * returned by obs_property_list_item_name() / obs_property_list_item_string() straight into a json value. nlohmann::json constructs a std::string from it, which calls strlen(NULL) and segfaults inside the plugin.

The macOS ScreenCaptureKit source (screen_capture) registers application list items whose name can be NULL (applications without a localized name), so requesting the application (or window) property items of such a source kills OBS.

Observed on OBS 32.1.2 / obs-websocket 5.7.3 / macOS 26.5. Crash report faulting thread:

libsystem_platform.dylib  _platform_strlen
obs-websocket             (GetListPropertyItems → json assignment)
obs-websocket             (RequestHandler::GetInputPropertiesListPropertyItems)

Reproduction (obs-websocket 5.x client):

  1. CreateInput with inputKind: "screen_capture", inputSettings: {"type": 2}.
  2. GetInputPropertiesListPropertyItems with propertyName: "application".
  3. OBS exits with SIGSEGV.

This change substitutes an empty string for NULL names / string values, matching how obs_data treats missing strings, so the request returns the list instead of crashing.

Motivation and Context

Fixes a reproducible crash triggered by a plain request; a websocket client should never be able to take OBS down.

How Has This Been Tested?

Code change is a null guard only; reproduced the crash on macOS as above. (Not rebuilt locally — please run CI.)

Types of changes

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

Checklist:

  • My code has been run through clang-format.
  • I have read the contributing document.
  • My code is not on the master branch.
  • The code has been tested.
  • All commit messages are properly formatted and commits squashed where appropriate.
  • I have included updates to all appropriate documentation.

@xiaoshao9704
xiaoshao9704 force-pushed the fix/list-property-null-strings branch from edde173 to 583e1bc Compare September 16, 2026 09:50
xiaoshao9704 added a commit to xiaoshao9704/hearth that referenced this pull request Sep 16, 2026
编码器本就是简单输出模式的一个配置项,没必要让用户回 OBS 改;按平台给候选,
选了这台机器没有的硬件编码器时 OBS 会在开播那步报错,把它的原话显示出来。

macOS 上只写设置的源一帧都不出(本机实测:换显示器 UUID、换采集类型、重写设置都不行,
日志恒为 init_screen_stream: Invalid target display ID)。上游 mac-sck 的采集初始化只认
一份异步取回的可共享内容列表,而那份列表只在打开源属性时才重新拉,所以属性窗口在 macOS
是功能必需。obs-websocket 的枚举请求本可顺带触发重建,但它会崩 OBS(5.7.4 仍未修,
已提上游 PR obsproject/obs-websocket#1355)。

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
xiaoshao9704 added a commit to xiaoshao9704/hearth that referenced this pull request Sep 17, 2026
新增 listObsWindows:确保「Hearth 画面」源在(不切场景、不弹窗)之后枚举 screen_capture
的 window 属性,滤掉占位项、空名与禁用项。只枚举 window 这一个属性——application 与
display_uuid 是字符串格式的列表,占位项的值是空指针、obs-websocket 5.7.3/5.7.4 未判空,
枚举即让 OBS 段错误(已提上游 PR obsproject/obs-websocket#1355);Windows 的窗口清单同为
字符串格式、没验过,一律不碰,那边仍走壳的清单或「到 OBS 里自己选」。

配套两处:splitObsWindowLabel 把「[应用名] 窗口标题」拆开,供界面按应用分组;选定目标后
obsCaptureToTarget 不再强制弹属性窗口——让 SCK 重建可共享内容列表这件事,列窗口那一步已经
顺带做掉(与打开属性窗口同走 obs_source_properties())。

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@tt2468

tt2468 commented Nov 1, 2026

Copy link
Copy Markdown
Member

Thanks for the contribution. Do you mind force pushing the change to use the utils prefix?

obs_property_list_item_name() and obs_property_list_item_string() can return
NULL for items registered by plugins (the macOS ScreenCaptureKit source lists
applications without a localized name). Assigning a NULL const char* to a
json value calls strlen(NULL), so GetInputPropertiesListPropertyItems on such
a source crashed OBS with SIGSEGV inside obs-websocket (observed on OBS 32.1.2
/ obs-websocket 5.7.3 / macOS 26.5). Substitute an empty string instead.
@cursor
cursor Bot force-pushed the fix/list-property-null-strings branch from 583e1bc to 60aa2d7 Compare November 1, 2026 11:13

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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants