瀏覽代碼

libobs: Fix possible crash with filters

This crash happened when a filter was mistakenly used as a regular
source due to an unrelated bug in filter code and scene loading code.
The filter and the source it belongs to both had the same names, and the
source loading code found the filter and mistakenly used it as the
source instead of the actual source with the same name.
jp9000 9 年之前
父節點
當前提交
f23974ab64
共有 1 個文件被更改,包括 16 次插入0 次删除
  1. 16 0
      libobs/obs-source.c

+ 16 - 0
libobs/obs-source.c

@@ -2666,6 +2666,18 @@ void obs_source_process_filter_begin(obs_source_t *filter,
 
 	target       = obs_filter_get_target(filter);
 	parent       = obs_filter_get_parent(filter);
+
+	if (!target) {
+		blog(LOG_INFO, "filter '%s' being processed with no target!",
+				filter->context.name);
+		return;
+	}
+	if (!parent) {
+		blog(LOG_INFO, "filter '%s' being processed with no parent!",
+				filter->context.name);
+		return;
+	}
+
 	target_flags = target->info.output_flags;
 	parent_flags = parent->info.output_flags;
 	cx           = get_base_width(target);
@@ -2724,6 +2736,10 @@ void obs_source_process_filter_tech_end(obs_source_t *filter, gs_effect_t *effec
 
 	target       = obs_filter_get_target(filter);
 	parent       = obs_filter_get_parent(filter);
+
+	if (!target || !parent)
+		return;
+
 	target_flags = target->info.output_flags;
 	parent_flags = parent->info.output_flags;