]> git.sesse.net Git - vlc/commitdiff
Check malloc return value and cleanup if allocation failed.
authorJean-Paul Saman <jpsaman@videolan.org>
Sat, 10 May 2008 17:49:29 +0000 (19:49 +0200)
committerJean-Paul Saman <jpsaman@videolan.org>
Sat, 10 May 2008 18:01:11 +0000 (20:01 +0200)
modules/access/rtmp/rtmp_amf_flv.c

index e0f3e7d7bffaebda804c8b6f53808817e4045ac9..27011b84f19da39f2eb14c761a674a2f42ab859b 100644 (file)
@@ -430,7 +430,12 @@ rtmp_connect_active( rtmp_control_thread_t *p_thread )
     free( tmp_buffer );
 
     tmp_url = (char *) malloc( strlen( "rtmp://") + strlen( p_thread->url.psz_buffer ) + 1 );
-    /* FIXME: Handle error case when malloc FAILS */
+    if( !tmp_url )
+    {
+        free( rtmp_body->body );
+        free( rtmp_body );
+        return -1;
+    }
     sprintf( tmp_url, "rtmp://%s", p_thread->url.psz_buffer );
     tmp_buffer = amf_encode_object_variable( "tcUrl",
         AMF_DATATYPE_STRING, tmp_url );
@@ -1853,8 +1858,12 @@ rtmp_encode_NetStream_play_reset_onStatus( rtmp_control_thread_t *p_thread, char
     free( tmp_buffer );
 
     description = (char *) malloc( strlen( "Playing and resetting ") + strlen( psz_media ) + strlen( "." ) + 1 );
-    /* FIXME: Handle error case when malloc FAILS */
-
+    if( !description )
+    {
+        free( rtmp_body->body );
+        free( rtmp_body );
+        return NULL;
+    }
     sprintf( description, "Playing and resetting %s.", psz_media );
     tmp_buffer = amf_encode_object_variable( "description",
         AMF_DATATYPE_STRING, description );
@@ -1935,7 +1944,12 @@ rtmp_encode_NetStream_play_start_onStatus( rtmp_control_thread_t *p_thread, char
     free( tmp_buffer );
 
     description = (char *) malloc( strlen( "Started playing ") + strlen( psz_media ) + strlen( "." ) + 1 );
-    /* FIXME: Handle error case when MALLOC FAILS */
+    if( !description )
+    {
+        free( rtmp_body->body );
+        free( rtmp_body );
+        return NULL;
+    }
 
     sprintf( description, "Started playing %s.", psz_media );
     tmp_buffer = amf_encode_object_variable( "description",