]> git.sesse.net Git - vlc/commitdiff
Check asprintf return value.
authorRémi Duraffort <ivoire@videolan.org>
Wed, 13 Aug 2008 20:35:34 +0000 (22:35 +0200)
committerRémi Duraffort <ivoire@videolan.org>
Wed, 13 Aug 2008 21:25:50 +0000 (23:25 +0200)
modules/codec/cmml/intf.c
modules/codec/realaudio.c
modules/control/http/util.c
modules/demux/asf/libasf.c

index 5f58b303d318a92b075c96c3d08d84d46f685ef6..97040969b2222b16fda313f2f82dd912eb866249 100644 (file)
@@ -584,7 +584,8 @@ char *GetTimedURIFragmentForTime( int seconds )
 {
     char *psz_time;
 
-    asprintf( &psz_time, "%d", seconds );
+    if( asprintf( &psz_time, "%d", seconds ) == -1 )
+        return NULL;
     return psz_time;
 }
 
index c4969087521ab93e7a9b82e4a1e5805c32ccd9cd..69308279f48bb63d61d19be4e5e0d517e493c642 100644 (file)
@@ -345,19 +345,22 @@ static int OpenDll( decoder_t *p_dec )
     for( i = 0; ppsz_path[i]; i++ )
     {
         /* Old format */
-        asprintf( &psz_dll, "%s/%4.4s.so.6.0", ppsz_path[i],
-                  (char *)&p_dec->fmt_in.i_codec );
-        i_result = OpenNativeDll( p_dec, ppsz_path[i], psz_dll );
-        free( psz_dll );
-        if( i_result == VLC_SUCCESS ) return VLC_SUCCESS;
+        if( asprintf( &psz_dll, "%s/%4.4s.so.6.0", ppsz_path[i],
+                  (char *)&p_dec->fmt_in.i_codec ) != -1 )
+        {
+            i_result = OpenNativeDll( p_dec, ppsz_path[i], psz_dll );
+            free( psz_dll );
+            if( i_result == VLC_SUCCESS ) return VLC_SUCCESS;
+        }
 
         /* New format */
-        asprintf( &psz_dll, "%s/%4.4s.so", ppsz_path[i],
-                  (char *)&p_dec->fmt_in.i_codec );
-        i_result = OpenNativeDll( p_dec, ppsz_path[i], psz_dll );
-        free( psz_dll );
-        if( i_result == VLC_SUCCESS ) return VLC_SUCCESS;
-
+        if( asprintf( &psz_dll, "%s/%4.4s.so", ppsz_path[i],
+                  (char *)&p_dec->fmt_in.i_codec ) != -1 )
+        {
+            i_result = OpenNativeDll( p_dec, ppsz_path[i], psz_dll );
+            free( psz_dll );
+            if( i_result == VLC_SUCCESS ) return VLC_SUCCESS;
+        }
     }
 #endif
 
@@ -366,18 +369,22 @@ static int OpenDll( decoder_t *p_dec )
     for( i = 0; ppsz_path[i]; i++ )
     {
         /* New format */
-        asprintf( &psz_dll, "%s\\%4.4s.dll", ppsz_path[i],
-                  (char *)&p_dec->fmt_in.i_codec );
-        i_result = OpenWin32Dll( p_dec, ppsz_path[i], psz_dll );
-        free( psz_dll );
-        if( i_result == VLC_SUCCESS ) return VLC_SUCCESS;
+        if( asprintf( &psz_dll, "%s\\%4.4s.dll", ppsz_path[i],
+                  (char *)&p_dec->fmt_in.i_codec ) != -1 )
+        {
+            i_result = OpenWin32Dll( p_dec, ppsz_path[i], psz_dll );
+            free( psz_dll );
+            if( i_result == VLC_SUCCESS ) return VLC_SUCCESS;
+        }
 
         /* Old format */
-        asprintf( &psz_dll, "%s\\%4.4s3260.dll", ppsz_path[i],
-                  (char *)&p_dec->fmt_in.i_codec );
-        i_result = OpenWin32Dll( p_dec, ppsz_path[i], psz_dll );
-        free( psz_dll );
-        if( i_result == VLC_SUCCESS ) return VLC_SUCCESS;
+        if( asprintf( &psz_dll, "%s\\%4.4s3260.dll", ppsz_path[i],
+                  (char *)&p_dec->fmt_in.i_codec ) != -1 )
+        {
+            i_result = OpenWin32Dll( p_dec, ppsz_path[i], psz_dll );
+            free( psz_dll );
+            if( i_result == VLC_SUCCESS ) return VLC_SUCCESS;
+        }
     }
 #endif
 
index 067d4bb784d7982b6455a643b0bea18dac74e1e3..cd84f685864cd359956b9dad05745871a38bf8d6 100644 (file)
@@ -315,13 +315,14 @@ int ParseDirectory( intf_thread_t *p_intf, char *psz_root,
 
                 if( b_index && ( p = strstr( f->file, "index." ) ) )
                 {
-                    asprintf( &psz_redir, "%s%s", f->name, p );
-
-                    msg_Dbg( p_intf, "redir=%s -> %s", psz_redir, f->name );
-                    f->p_redir2 = httpd_RedirectNew( p_sys->p_httpd_host,
-                                                     f->name, psz_redir );
+                    if( asprintf( &psz_redir, "%s%s", f->name, p ) != -1 )
+                    {
+                        msg_Dbg( p_intf, "redir=%s -> %s", psz_redir, f->name );
+                        f->p_redir2 = httpd_RedirectNew( p_sys->p_httpd_host,
+                                                         f->name, psz_redir );
 
-                    free( psz_redir );
+                        free( psz_redir );
+                    }
                 }
             }
         }
index 6c75aa7367e995ff10376677403249c774220d0a..46183cb4c6b5d37b4e231a736fbc62edfa8cdfc1 100644 (file)
@@ -1190,17 +1190,20 @@ static int ASF_ReadObject_extended_content_description( stream_t *s,
         else if( i_type == 3 )
         {
             /* DWord */
-            asprintf( &p_ec->ppsz_value[i], "%d", ASF_READ4() );
+            if( asprintf( &p_ec->ppsz_value[i], "%d", ASF_READ4() ) == -1 )
+                p_ec->ppsz_value[i] = NULL;
         }
         else if( i_type == 4 )
         {
             /* QWord */
-            asprintf( &p_ec->ppsz_value[i], "%"PRId64, ASF_READ8() );
+            if( asprintf( &p_ec->ppsz_value[i], "%"PRId64, ASF_READ8() ) == -1 )
+                p_ec->ppsz_value[i] = NULL;
         }
         else if( i_type == 5 )
         {
             /* Word */
-            asprintf( &p_ec->ppsz_value[i], "%d", ASF_READ2() );
+            if( asprintf( &p_ec->ppsz_value[i], "%d", ASF_READ2() ) == -1 )
+                p_ec->ppsz_value[i] = NULL;
         }
         else
         {