Merge pull request #404 from Palakis/bugfix/memory-leaks

Fix memory leaks in GetCurrentProfile, GetCurrentSceneCollection and Heartbeat event
This commit is contained in:
Stéphane Lepin 2020-01-29 12:28:48 +01:00 committed by GitHub
commit d78ed32df5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 4 deletions

View File

@ -857,7 +857,9 @@ void WSEvents::Heartbeat() {
pulse = !pulse;
obs_data_set_bool(data, "pulse", pulse);
obs_data_set_string(data, "current-profile", obs_frontend_get_current_profile());
char* currentProfile = obs_frontend_get_current_profile();
obs_data_set_string(data, "current-profile", currentProfile);
bfree(currentProfile);
OBSSourceAutoRelease currentScene = obs_frontend_get_current_scene();
obs_data_set_string(data, "current-scene", obs_source_get_name(currentScene));

View File

@ -39,7 +39,9 @@ HandlerResponse WSRequestHandler::HandleSetCurrentProfile(WSRequestHandler* req)
*/
HandlerResponse WSRequestHandler::HandleGetCurrentProfile(WSRequestHandler* req) {
OBSDataAutoRelease response = obs_data_create();
obs_data_set_string(response, "profile-name", obs_frontend_get_current_profile());
char* currentProfile = obs_frontend_get_current_profile();
obs_data_set_string(response, "profile-name", currentProfile);
bfree(currentProfile);
return req->SendOKResponse(response);
}

View File

@ -39,8 +39,10 @@ HandlerResponse WSRequestHandler::HandleSetCurrentSceneCollection(WSRequestHandl
*/
HandlerResponse WSRequestHandler::HandleGetCurrentSceneCollection(WSRequestHandler* req) {
OBSDataAutoRelease response = obs_data_create();
obs_data_set_string(response, "sc-name",
obs_frontend_get_current_scene_collection());
char* sceneCollection = obs_frontend_get_current_scene_collection();
obs_data_set_string(response, "sc-name", sceneCollection);
bfree(sceneCollection);
return req->SendOKResponse(response);
}