mirror of
https://github.com/mpv-player/mpv
synced 2025-02-15 03:27:35 +00:00
video_out: fix crash when VO autoselection fails
init_best_video_out() did not manage the memory for vo->window_title correctly, and free'd it twice when initialization failed (that's due to talloc_free_children() being called). When the next VO was tried, it reused the dangling pointer. Initialize this member somewhere else lazily instead.
This commit is contained in:
parent
850f2b4511
commit
1b7b0c93a8
@ -306,7 +306,6 @@ struct vo *init_best_video_out(struct MPOpts *opts,
|
|||||||
.input_ctx = input_ctx,
|
.input_ctx = input_ctx,
|
||||||
.event_fd = -1,
|
.event_fd = -1,
|
||||||
.registered_fd = -1,
|
.registered_fd = -1,
|
||||||
.window_title = talloc_strdup(vo, ""),
|
|
||||||
};
|
};
|
||||||
// first try the preferred drivers, with their optional subdevice param:
|
// first try the preferred drivers, with their optional subdevice param:
|
||||||
if (vo_list && vo_list[0])
|
if (vo_list && vo_list[0])
|
||||||
@ -351,7 +350,7 @@ struct vo *init_best_video_out(struct MPOpts *opts,
|
|||||||
return vo; // success!
|
return vo; // success!
|
||||||
talloc_free_children(vo);
|
talloc_free_children(vo);
|
||||||
}
|
}
|
||||||
free(vo);
|
talloc_free(vo);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -488,6 +487,8 @@ void calc_src_dst_rects(struct vo *vo, int src_width, int src_height,
|
|||||||
// you need to keep the string for an extended period of time.
|
// you need to keep the string for an extended period of time.
|
||||||
const char *vo_get_window_title(struct vo *vo)
|
const char *vo_get_window_title(struct vo *vo)
|
||||||
{
|
{
|
||||||
|
if (!vo->window_title)
|
||||||
|
vo->window_title = talloc_strdup(vo, "");
|
||||||
return vo->window_title;
|
return vo->window_title;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user