]> git.sesse.net Git - vlc/commitdiff
Fix memory leak and error handling
authorRémi Denis-Courmont <rdenis@simphalempin.com>
Sat, 14 Jun 2008 21:39:34 +0000 (00:39 +0300)
committerRémi Denis-Courmont <rdenis@simphalempin.com>
Sat, 14 Jun 2008 21:40:46 +0000 (00:40 +0300)
modules/codec/realvideo.c

index 3d7f20718983cf29ef8f7e15d7c849f07220f38e..40d0542c72d4b5d9769d3400c7b7a8cd33c97427 100644 (file)
@@ -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