]> git.sesse.net Git - vlc/commitdiff
Check asprintf return value.
authorRémi Duraffort <ivoire@videolan.org>
Wed, 13 Feb 2008 00:14:37 +0000 (00:14 +0000)
committerRémi Duraffort <ivoire@videolan.org>
Wed, 13 Feb 2008 00:14:37 +0000 (00:14 +0000)
src/misc/update.c

index 8a2e9b34cd3d981b5d04328282b03b49e5c8c454..b85a9cda42614d8920bfb2a816b08bcbb49a3330 100644 (file)
@@ -1178,15 +1178,17 @@ int update_CompareReleaseToCurrent( update_t *p_update )
 static char *size_str( long int l_size )
 {
     char *psz_tmp = NULL;
+    int i_retval = 0;
     if( l_size >> 30 )
-        asprintf( &psz_tmp, "%.1f GB", (float)l_size/(1<<30) );
+        i_retval = asprintf( &psz_tmp, "%.1f GB", (float)l_size/(1<<30) );
     else if( l_size >> 20 )
-        asprintf( &psz_tmp, "%.1f MB", (float)l_size/(1<<20) );
+        i_retval = asprintf( &psz_tmp, "%.1f MB", (float)l_size/(1<<20) );
     else if( l_size >> 10 )
-        asprintf( &psz_tmp, "%.1f kB", (float)l_size/(1<<10) );
+        i_retval = asprintf( &psz_tmp, "%.1f kB", (float)l_size/(1<<10) );
     else
-        asprintf( &psz_tmp, "%ld B", l_size );
-    return psz_tmp;
+        i_retval = asprintf( &psz_tmp, "%ld B", l_size );
+
+    return i_retval == -1 ? NULL : psz_tmp;
 }