Commit 261fd89d authored by Jean-Paul Saman's avatar Jean-Paul Saman

Check malloc return value and cleanup if allocation failed.

parent 38aaaeb3
...@@ -430,7 +430,12 @@ rtmp_connect_active( rtmp_control_thread_t *p_thread ) ...@@ -430,7 +430,12 @@ rtmp_connect_active( rtmp_control_thread_t *p_thread )
free( tmp_buffer ); free( tmp_buffer );
tmp_url = (char *) malloc( strlen( "rtmp://") + strlen( p_thread->url.psz_buffer ) + 1 ); 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 ); sprintf( tmp_url, "rtmp://%s", p_thread->url.psz_buffer );
tmp_buffer = amf_encode_object_variable( "tcUrl", tmp_buffer = amf_encode_object_variable( "tcUrl",
AMF_DATATYPE_STRING, tmp_url ); AMF_DATATYPE_STRING, tmp_url );
...@@ -1853,8 +1858,12 @@ rtmp_encode_NetStream_play_reset_onStatus( rtmp_control_thread_t *p_thread, char ...@@ -1853,8 +1858,12 @@ rtmp_encode_NetStream_play_reset_onStatus( rtmp_control_thread_t *p_thread, char
free( tmp_buffer ); free( tmp_buffer );
description = (char *) malloc( strlen( "Playing and resetting ") + strlen( psz_media ) + strlen( "." ) + 1 ); 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 ); sprintf( description, "Playing and resetting %s.", psz_media );
tmp_buffer = amf_encode_object_variable( "description", tmp_buffer = amf_encode_object_variable( "description",
AMF_DATATYPE_STRING, description ); AMF_DATATYPE_STRING, description );
...@@ -1935,7 +1944,12 @@ rtmp_encode_NetStream_play_start_onStatus( rtmp_control_thread_t *p_thread, char ...@@ -1935,7 +1944,12 @@ rtmp_encode_NetStream_play_start_onStatus( rtmp_control_thread_t *p_thread, char
free( tmp_buffer ); free( tmp_buffer );
description = (char *) malloc( strlen( "Started playing ") + strlen( psz_media ) + strlen( "." ) + 1 ); 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 ); sprintf( description, "Started playing %s.", psz_media );
tmp_buffer = amf_encode_object_variable( "description", tmp_buffer = amf_encode_object_variable( "description",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment