Skip to content

libobs: clear encoder_group on obs_encoder_set_group(enc, NULL) - #688

Merged
zackees merged 2 commits into
masterfrom
fix/483-encoder-group-null
Oct 14, 2026
Merged

zackees merged 2 commits into
masterfrom
fix/483-encoder-group-null

Conversation

@zackees

@zackees zackees commented Oct 14, 2026

Copy link
Copy Markdown
Member

Fixes #483

obs_encoder_set_group(enc, NULL) released the group's reference but left encoder->encoder_group pointing at the old group; a later set to another group released a reference the encoder no longer held (use-after-free). Fix: clear the pointer after erasing the encoder from the old group. Encoder-group code is C-only (no Rust port), so OFF and ON behave the same.

Commits: RED d8e5833cd (new test_encoder_group_null, runs under xvfb-run when available), GREEN 8f7d5b9da (one line in libobs/obs-encoder.c).

RED (rust/tools/linux-validate/run.sh, OFF build; the script stops at the first failing build):

72/195 Test #72: test_encoder_group_null ***Failed
debug: encoder 'enc' destroyed
[ ERROR ] --- (nil) == (nil)   (test_encoder_group_null.c:106, weak encoder gone while second group holds it)
99% tests passed, 1 tests failed out of 195

GREEN:

[OFF] 72/195 test_encoder_group_null Passed; 100% tests passed, 0 failed out of 195
[ON]  72/195 test_encoder_group_null Passed; 100% tests passed, 0 failed out of 195

./lint ok; local-gate run passed (lint, rust-test, cross, tier2-linux), commit stamped.

Local-Gate: v1 tree=a5d462a22152e13481fa439e6fc3280b2c31ee65 secs=354 lanes=lint:run,rust-test:run,cross:run,tier2-linux:run
Ci-Attestation: {"at":1791959598,"gate":"rust/all/fmt","host":"linux-x86_64","key":"11e6efb0eb3422baba17407e6b45ab4914ecea800b4c54bc1f889fc54c3bb474","lane":"lint","parents":["d8e5833cd841ca4fa66297c93bcc932507ef718c"],"secs":23,"stamp":"71b016aab64fede302e4ded8626cbcf2","tree":"a5d462a22152e13481fa439e6fc3280b2c31ee65","v":1,"via":"run"}
Ci-Attestation: {"at":1791959598,"gate":"rust/x86_64-unknown-linux-gnu/clippy","host":"linux-x86_64","key":"11e6efb0eb3422baba17407e6b45ab4914ecea800b4c54bc1f889fc54c3bb474","lane":"lint","parents":["d8e5833cd841ca4fa66297c93bcc932507ef718c"],"secs":23,"stamp":"6ab56f51935dac67b2c8e4e1f8c369fa","tree":"a5d462a22152e13481fa439e6fc3280b2c31ee65","v":1,"via":"run"}
Ci-Attestation: {"at":1791959599,"gate":"rust/x86_64-unknown-linux-gnu/test","host":"linux-x86_64","key":"974b4660ab9257a9eff35944e99534537ed29dba8fc2193a8ee26086e6905c92","lane":"rust-test","parents":["d8e5833cd841ca4fa66297c93bcc932507ef718c"],"secs":101,"stamp":"4d532bf65c42f13057dcffe09265e271","tree":"a5d462a22152e13481fa439e6fc3280b2c31ee65","v":1,"via":"run"}
Ci-Attestation: {"at":1791959599,"gate":"rust/x86_64-pc-windows-msvc/clippy","host":"linux-x86_64","key":"017b8184b97822682705de53c67e6215f986d043dd31957be3ed16ae5feb92db","lane":"cross","parents":["d8e5833cd841ca4fa66297c93bcc932507ef718c"],"secs":79,"stamp":"5cec04569a3b5b4102f337d59c917a11","tree":"a5d462a22152e13481fa439e6fc3280b2c31ee65","v":1,"via":"run"}
Ci-Attestation: {"at":1791959599,"gate":"rust/x86_64-pc-windows-msvc/dylint","host":"linux-x86_64","key":"017b8184b97822682705de53c67e6215f986d043dd31957be3ed16ae5feb92db","lane":"cross","parents":["d8e5833cd841ca4fa66297c93bcc932507ef718c"],"secs":79,"stamp":"5bf996bfedfe358ec1bc6da6fc0f38e8","tree":"a5d462a22152e13481fa439e6fc3280b2c31ee65","v":1,"via":"run"}
Ci-Attestation: {"at":1791959599,"gate":"rust/aarch64-apple-darwin/clippy","host":"linux-x86_64","key":"017b8184b97822682705de53c67e6215f986d043dd31957be3ed16ae5feb92db","lane":"cross","parents":["d8e5833cd841ca4fa66297c93bcc932507ef718c"],"secs":79,"stamp":"dffea013cd93c77320e6dfc3e262088f","tree":"a5d462a22152e13481fa439e6fc3280b2c31ee65","v":1,"via":"run"}
Ci-Attestation: {"at":1791959599,"gate":"rust/aarch64-apple-darwin/dylint","host":"linux-x86_64","key":"017b8184b97822682705de53c67e6215f986d043dd31957be3ed16ae5feb92db","lane":"cross","parents":["d8e5833cd841ca4fa66297c93bcc932507ef718c"],"secs":79,"stamp":"47ffb886c2077dfbc616225a1fd4e38b","tree":"a5d462a22152e13481fa439e6fc3280b2c31ee65","v":1,"via":"run"}
Ci-Attestation: {"at":1791959599,"gate":"rust/x86_64-apple-darwin/clippy","host":"linux-x86_64","key":"017b8184b97822682705de53c67e6215f986d043dd31957be3ed16ae5feb92db","lane":"cross","parents":["d8e5833cd841ca4fa66297c93bcc932507ef718c"],"secs":79,"stamp":"e218db34edddd62ef0ac4d3f5448e42f","tree":"a5d462a22152e13481fa439e6fc3280b2c31ee65","v":1,"via":"run"}
Ci-Attestation: {"at":1791959599,"gate":"rust/x86_64-apple-darwin/dylint","host":"linux-x86_64","key":"017b8184b97822682705de53c67e6215f986d043dd31957be3ed16ae5feb92db","lane":"cross","parents":["d8e5833cd841ca4fa66297c93bcc932507ef718c"],"secs":79,"stamp":"58e19a93153106e489665677aeeca931","tree":"a5d462a22152e13481fa439e6fc3280b2c31ee65","v":1,"via":"run"}
Ci-Attestation: {"at":1791959599,"gate":"cpp/linux-x64/tier2","host":"linux-x86_64","key":"10150c265b42e2fd1b6e5edf48edc663754ef14ebdca3613336f03f6ad87586c","lane":"tier2-linux","parents":["d8e5833cd841ca4fa66297c93bcc932507ef718c"],"secs":150,"stamp":"f964b97b5ff833e7f07a3a8af3e9623f","tree":"a5d462a22152e13481fa439e6fc3280b2c31ee65","v":1,"via":"run"}
@zackees
zackees merged commit 968d28c into master Oct 14, 2026
21 checks passed
@zackees
zackees deleted the fix/483-encoder-group-null branch October 26, 2026 15:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

bug: libobs: obs_encoder_set_group(enc, NULL) leaves a stale group pointer on the encoder

1 participant