]> git.sesse.net Git - vlc/commitdiff
Recover from documented undefined value return on gnu platforms.
authorJP Dinger <jpd@videolan.org>
Fri, 22 May 2009 01:05:14 +0000 (03:05 +0200)
committerJP Dinger <jpd@videolan.org>
Fri, 22 May 2009 01:05:14 +0000 (03:05 +0200)
src/input/item.c

index c82b2a0939659be1e95b70ed373d8aa8c181014d..2397c13c55c4ce397afa406cf9b56a7499a2acaa 100644 (file)
@@ -16,9 +16,9 @@
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
  *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
  *****************************************************************************/
 
 #ifdef HAVE_CONFIG_H
@@ -371,29 +371,32 @@ void input_item_SetURI( input_item_t *p_i, const char *psz_uri )
     /* The name is NULL: fill it with everything except login and password */
     if( !p_i->psz_name )
     {
+        int r;
         vlc_url_t url;
         vlc_UrlParse( &url, psz_uri, 0 );
         if( url.psz_protocol )
         {
             if( url.i_port > 0 )
-                asprintf( &p_i->psz_name, "%s://%s:%d%s", url.psz_protocol,
+                r=asprintf( &p_i->psz_name, "%s://%s:%d%s", url.psz_protocol,
                           url.psz_host, url.i_port,
                           url.psz_path ? url.psz_path : "" );
             else
-                asprintf( &p_i->psz_name, "%s://%s%s", url.psz_protocol,
+                r=asprintf( &p_i->psz_name, "%s://%s%s", url.psz_protocol,
                           url.psz_host ? url.psz_host : "",
                           url.psz_path ? url.psz_path : "" );
         }
         else
         {
             if( url.i_port > 0 )
-                asprintf( &p_i->psz_name, "%s:%d%s", url.psz_host, url.i_port,
+                r=asprintf( &p_i->psz_name, "%s:%d%s", url.psz_host, url.i_port,
                           url.psz_path ? url.psz_path : "" );
             else
-                asprintf( &p_i->psz_name, "%s%s", url.psz_host,
+                r=asprintf( &p_i->psz_name, "%s%s", url.psz_host,
                           url.psz_path ? url.psz_path : "" );
         }
         vlc_UrlClean( &url );
+        if( -1==r )
+            p_i->psz_name=NULL; /* recover from undefined value */
     }
 
     vlc_mutex_unlock( &p_i->lock );