libobs: Prevent infinite source recursion

Changed the design from using obs_source::enum_refs to just simply
preventing infinite source recursion in general, rather than allowing it
through the enum_refs variable.  obs_source_add_child has been changed
so that it now returns a boolean, and if the function fails, it means
that the child cannot be added due to that potential recursion.
This commit is contained in:
jp9000
2014-12-27 20:21:22 -08:00
parent 1ed4c2a920
commit e29a1fd367
4 changed files with 36 additions and 23 deletions

View File

@@ -552,6 +552,12 @@ obs_sceneitem_t *obs_scene_add(obs_scene_t *scene, obs_source_t *source)
return NULL;
}
if (!obs_source_add_child(scene->source, source)) {
blog(LOG_WARNING, "Failed to add source to scene due to "
"infinite source recursion");
return NULL;
}
item = bzalloc(sizeof(struct obs_scene_item));
item->source = source;
item->visible = true;
@@ -563,7 +569,6 @@ obs_sceneitem_t *obs_scene_add(obs_scene_t *scene, obs_source_t *source)
matrix4_identity(&item->box_transform);
obs_source_addref(source);
obs_source_add_child(scene->source, source);
pthread_mutex_lock(&scene->mutex);