UI: Fix possible use-after-free of obs_source_t
Also removes an implicit pair of successive obs_source_getref and obs_source_release calls from OBSSource.
This commit is contained in:
parent
8ce4a2a154
commit
23a0b7cacd
@ -114,7 +114,7 @@ struct OBSStudioAPI : obs_frontend_callbacks {
|
|||||||
struct obs_frontend_source_list *sources) override
|
struct obs_frontend_source_list *sources) override
|
||||||
{
|
{
|
||||||
for (int i = 0; i < main->ui->transitions->count(); i++) {
|
for (int i = 0; i < main->ui->transitions->count(); i++) {
|
||||||
obs_source_t *tr = main->ui->transitions->itemData(i)
|
OBSSource tr = main->ui->transitions->itemData(i)
|
||||||
.value<OBSSource>();
|
.value<OBSSource>();
|
||||||
|
|
||||||
if (!tr)
|
if (!tr)
|
||||||
|
@ -564,7 +564,7 @@ void OBSBasic::RenameTransition()
|
|||||||
{
|
{
|
||||||
QAction *action = reinterpret_cast<QAction *>(sender());
|
QAction *action = reinterpret_cast<QAction *>(sender());
|
||||||
QVariant variant = action->property("transition");
|
QVariant variant = action->property("transition");
|
||||||
obs_source_t *transition = variant.value<OBSSource>();
|
OBSSource transition = variant.value<OBSSource>();
|
||||||
|
|
||||||
string name;
|
string name;
|
||||||
QString placeHolderText = QT_UTF8(obs_source_get_name(transition));
|
QString placeHolderText = QT_UTF8(obs_source_get_name(transition));
|
||||||
|
@ -733,7 +733,7 @@ obs_data_array_t *OBSBasic::SaveProjectors()
|
|||||||
switch (type) {
|
switch (type) {
|
||||||
case ProjectorType::Scene:
|
case ProjectorType::Scene:
|
||||||
case ProjectorType::Source: {
|
case ProjectorType::Source: {
|
||||||
obs_source_t *source = projector->GetSource();
|
OBSSource source = projector->GetSource();
|
||||||
const char *name = obs_source_get_name(source);
|
const char *name = obs_source_get_name(source);
|
||||||
obs_data_set_string(data, "name", name);
|
obs_data_set_string(data, "name", name);
|
||||||
break;
|
break;
|
||||||
@ -5393,8 +5393,8 @@ void OBSBasic::on_actionAddScene_triggered()
|
|||||||
auto undo_fn = [](const std::string &data) {
|
auto undo_fn = [](const std::string &data) {
|
||||||
obs_source_t *t = obs_get_source_by_name(data.c_str());
|
obs_source_t *t = obs_get_source_by_name(data.c_str());
|
||||||
if (t) {
|
if (t) {
|
||||||
obs_source_release(t);
|
|
||||||
obs_source_remove(t);
|
obs_source_remove(t);
|
||||||
|
obs_source_release(t);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -2302,10 +2302,7 @@ static obs_source_t *CreateLabel(float pixelRatio)
|
|||||||
const char *text_source_id = "text_ft2_source";
|
const char *text_source_id = "text_ft2_source";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
OBSSource txtSource =
|
return obs_source_create_private(text_source_id, NULL, settings);
|
||||||
obs_source_create_private(text_source_id, NULL, settings);
|
|
||||||
|
|
||||||
return txtSource;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void SetLabelText(int sourceIndex, int px)
|
static void SetLabelText(int sourceIndex, int px)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user