[vlc-devel] commit: Check malloc return value and cleanup if allocation failed. ( Jean-Paul Saman )
git version control
git at videolan.org
Sat May 10 20:21:41 CEST 2008
vlc | branch: master | Jean-Paul Saman <jpsaman at videolan.org> | Sat May 10 19:49:29 2008 +0200| [261fd89df68f7e4e1a5926c365d060033a5ec30a]
Check malloc return value and cleanup if allocation failed.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=261fd89df68f7e4e1a5926c365d060033a5ec30a
---
modules/access/rtmp/rtmp_amf_flv.c | 22 ++++++++++++++++++----
1 files changed, 18 insertions(+), 4 deletions(-)
diff --git a/modules/access/rtmp/rtmp_amf_flv.c b/modules/access/rtmp/rtmp_amf_flv.c
index e0f3e7d..27011b8 100644
--- a/modules/access/rtmp/rtmp_amf_flv.c
+++ b/modules/access/rtmp/rtmp_amf_flv.c
@@ -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",
More information about the vlc-devel
mailing list