Kaynağa Gözat

UI: Don't std::move main in SetUndoProperties

main is used later in the function, making this undefined behavior.
Though we can move the scene_name string.

Detected by PVS Studio.
Richard Stanway 2 yıl önce
ebeveyn
işleme
a781f4a887
1 değiştirilmiş dosya ile 2 ekleme ve 2 silme
  1. 2 2
      UI/context-bar-controls.cpp

+ 2 - 2
UI/context-bar-controls.cpp

@@ -56,8 +56,8 @@ void SourceToolbar::SetUndoProperties(obs_source_t *source, bool repeatable)
 	if (!currentSceneSource)
 	if (!currentSceneSource)
 		return;
 		return;
 	std::string scene_name = obs_source_get_name(currentSceneSource);
 	std::string scene_name = obs_source_get_name(currentSceneSource);
-	auto undo_redo = [scene_name,
-			  main = std::move(main)](const std::string &data) {
+	auto undo_redo = [scene_name = std::move(scene_name),
+			  main](const std::string &data) {
 		OBSDataAutoRelease settings =
 		OBSDataAutoRelease settings =
 			obs_data_create_from_json(data.c_str());
 			obs_data_create_from_json(data.c_str());
 		OBSSourceAutoRelease source = obs_get_source_by_name(
 		OBSSourceAutoRelease source = obs_get_source_by_name(