Quellcode durchsuchen

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 vor 9 Jahren
Ursprung
Commit
f23974ab64
1 geänderte Dateien mit 16 neuen und 0 gelöschten Zeilen
  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);
 	target       = obs_filter_get_target(filter);
 	parent       = obs_filter_get_parent(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;
 	target_flags = target->info.output_flags;
 	parent_flags = parent->info.output_flags;
 	parent_flags = parent->info.output_flags;
 	cx           = get_base_width(target);
 	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);
 	target       = obs_filter_get_target(filter);
 	parent       = obs_filter_get_parent(filter);
 	parent       = obs_filter_get_parent(filter);
+
+	if (!target || !parent)
+		return;
+
 	target_flags = target->info.output_flags;
 	target_flags = target->info.output_flags;
 	parent_flags = parent->info.output_flags;
 	parent_flags = parent->info.output_flags;