summaryrefslogtreecommitdiffstats
path: root/libvo
diff options
context:
space:
mode:
authorUoti Urpala <uau@mplayer2.org>2012-07-12 19:04:57 +0300
committerUoti Urpala <uau@mplayer2.org>2012-07-16 21:08:42 +0300
commit0a1fc392b4cc45985d95eb6563f496a74bb3b306 (patch)
tree62f01cffd5864c1d1f627db499d2e5999d863246 /libvo
parent2ba8b91a97e7e873a522f365e41a293af980c91a (diff)
downloadmpv-0a1fc392b4cc45985d95eb6563f496a74bb3b306.tar.bz2
mpv-0a1fc392b4cc45985d95eb6563f496a74bb3b306.tar.xz
vo_vdpau: fix possible crash after preemption
Preemption recovery code could change the vc->vdp pointer when recreating the VDPAU device. However, some other code cached the value of vc->vdp in local variables over calls to handle_preemption(), and could then crash when using the stale value later. Make the device creation code keep the same vc->vdp instead of freeing and reallocating it, so that the old pointer value is never invalidated now.
Diffstat (limited to 'libvo')
-rw-r--r--libvo/vo_vdpau.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/libvo/vo_vdpau.c b/libvo/vo_vdpau.c
index a99cfeea7d..36ca7ab84b 100644
--- a/libvo/vo_vdpau.c
+++ b/libvo/vo_vdpau.c
@@ -456,9 +456,11 @@ static int win_x11_init_vdpau_procs(struct vo *vo)
{
struct vo_x11_state *x11 = vo->x11;
struct vdpctx *vc = vo->priv;
- talloc_free(vc->vdp); // In case this is reinitialization after preemption
- struct vdp_functions *vdp = talloc_zero(vc, struct vdp_functions);
- vc->vdp = vdp;
+ if (vc->vdp) // reinitialization after preemption
+ memset(vc->vdp, 0, sizeof(*vc->vdp));
+ else
+ vc->vdp = talloc_zero(vc, struct vdp_functions);
+ struct vdp_functions *vdp = vc->vdp;
VdpStatus vdp_st;
struct vdp_function {