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

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


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

vdpau: fix VRAM leak on error

(cherry picked from commit 5bf47e957dfb794dfb96acb9c928fc8d87205d35)

> http://git.videolan.org/gitweb.cgi/vlc/vlc-2.2.git/?a=commit;h=77db2e04bea273991ab7079a25b94afb59ec28f9
---

 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 cc60bb8..1fbb5fa 100644
--- a/modules/hw/vdpau/avcodec.c
+++ b/modules/hw/vdpau/avcodec.c
@@ -60,7 +60,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;
@@ -72,15 +72,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