[vlc-devel] commit: Fix memory leak and error handling ( Rémi Denis-Courmont )

git version control git at videolan.org
Sat Jun 14 23:38:54 CEST 2008


vlc | branch: master | Rémi Denis-Courmont <rdenis at simphalempin.com> | Sun Jun 15 00:39:34 2008 +0300| [cc6941a5134af40e0a41620215bf9efe8ab5ba94]

Fix memory leak and error handling

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

 modules/codec/realvideo.c |   21 +++++++++++++--------
 1 files changed, 13 insertions(+), 8 deletions(-)

diff --git a/modules/codec/realvideo.c b/modules/codec/realvideo.c
index 3d7f207..40d0542 100644
--- a/modules/codec/realvideo.c
+++ b/modules/codec/realvideo.c
@@ -274,26 +274,31 @@ static int InitVideo(decoder_t *p_dec)
         "\0"
     };
 
-    for( size_t i = 0; psz_paths[i]; i += strlen( psz_paths[i] ) + 1 )
+    for( size_t i = 0; psz_paths[i]; i += strlen( psz_paths + i ) + 1 )
     {
-        asprintf( &g_decode_path, "%s/drv4.so.6.0", psz_paths + i );
-        if( (p_sys->rv_handle = load_syms_linux(p_dec, g_decode_path)) )
+        if( asprintf( &g_decode_path, "%s/drv4.so.6.0", psz_paths + i ) != -1 )
         {
-            b_so_opened = true;
+            p_sys->rv_handle = load_syms_linux(p_dec, g_decode_path);
             free( g_decode_path );
+        }
+        if( p_sys->rv_handle )
+        {
+            b_so_opened = true;
             break;
         }
 
-        asprintf( &g_decode_path, "%s/drv3.so.6.0", psz_paths + i );
-        if( (p_sys->rv_handle = load_syms_linux(p_dec, g_decode_path)) )
+        if( asprintf( &g_decode_path, "%s/drv3.so.6.0", psz_paths + i ) != -1 )
         {
-            b_so_opened = true;
+            p_sys->rv_handle = load_syms_linux(p_dec, g_decode_path);
             free( g_decode_path );
+        }
+        if( p_sys->rv_handle )
+        {
+            b_so_opened = true;
             break;
         }
 
         msg_Dbg( p_dec, "Cannot load real decoder library: %s", g_decode_path);
-        free( g_decode_path );
     }
 #endif
 




More information about the vlc-devel mailing list