[vlc-commits] vdpau: fix VRAM leak on error

Rémi Denis-Courmont git at videolan.org
Sat Oct 4 15:32:02 CEST 2014


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sat Oct  4 16:04:44 2014 +0300| [5bf47e957dfb794dfb96acb9c928fc8d87205d35] | committer: Rémi Denis-Courmont

vdpau: fix VRAM leak on error

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=5bf47e957dfb794dfb96acb9c928fc8d87205d35
---

 modules/hw/vdpau/avcodec.c |   14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/modules/hw/vdpau/avcodec.c b/modules/hw/vdpau/avcodec.c
index f741f82..13a8cfd 100644
--- a/modules/hw/vdpau/avcodec.c
+++ b/modules/hw/vdpau/avcodec.c
@@ -58,7 +58,7 @@ struct vlc_va_sys_t
     uint16_t height;
 };
 
-static int Lock(vlc_va_t *va, void **opaque, uint8_t **data)
+static vlc_vdp_video_field_t *CreateSurface(vlc_va_t *va)
 {
     vlc_va_sys_t *sys = va->sys;
     VdpVideoSurface surface;
@@ -70,15 +70,23 @@ static int Lock(vlc_va_t *va, void **opaque, uint8_t **data)
     {
         msg_Err(va, "%s creation failure: %s", "video surface",
                 vdp_get_error_string(sys->vdp, err));
-        return VLC_EGENERIC;
+        return NULL;
     }
 
     vlc_vdp_video_field_t *field = vlc_vdp_video_create(sys->vdp, surface);
     if (unlikely(field == NULL))
+        vdp_video_surface_destroy(sys->vdp, surface);
+    return field;
+}
+
+static int Lock(vlc_va_t *va, void **opaque, uint8_t **data)
+{
+    vlc_vdp_video_field_t *field = CreateSurface(va);
+    if (unlikely(field == NULL))
         return VLC_ENOMEM;
 
-    *data = (void *)(uintptr_t)surface;
     *opaque = field;
+    *data = (void *)(uintptr_t)field->frame->surface;
     return VLC_SUCCESS;
 }
 



More information about the vlc-commits mailing list