[vlc-devel] commit: Don't override original pointer when realloc fails. ( 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:53:41 2008 +0200| [b3cb03feaa065b38f2b05219dc38fb78bd3d68cf]
Don't override original pointer when realloc fails.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=b3cb03feaa065b38f2b05219dc38fb78bd3d68cf
---
modules/access/rtmp/rtmp_amf_flv.c | 16 ++++++++++++----
1 files changed, 12 insertions(+), 4 deletions(-)
diff --git a/modules/access/rtmp/rtmp_amf_flv.c b/modules/access/rtmp/rtmp_amf_flv.c
index 27011b8..859bc12 100644
--- a/modules/access/rtmp/rtmp_amf_flv.c
+++ b/modules/access/rtmp/rtmp_amf_flv.c
@@ -2071,8 +2071,12 @@ rtmp_body_append( rtmp_body_t *rtmp_body, uint8_t *buffer, uint32_t length )
{
if( rtmp_body->length_body + length > rtmp_body->length_buffer )
{
+ uint8_t *tmp;
rtmp_body->length_buffer = rtmp_body->length_body + length;
- rtmp_body->body = (uint8_t *) realloc( rtmp_body->body, rtmp_body->length_buffer * sizeof( uint8_t ) );
+ tmp = realloc( rtmp_body->body,
+ rtmp_body->length_buffer * sizeof( uint8_t ) );
+ if( !tmp ) return;
+ rtmp_body->body = tmp;
}
memcpy( rtmp_body->body + rtmp_body->length_body, buffer, length );
@@ -2320,11 +2324,15 @@ static void
flv_rebuild( rtmp_control_thread_t *p_thread, rtmp_packet_t *rtmp_packet )
{
uint32_t length_tag, timestamp;
+ uint8_t *tmp;
- rtmp_packet->body->body = (uint8_t *) realloc( rtmp_packet->body->body,
- rtmp_packet->body->length_body + FLV_TAG_PREVIOUS_TAG_SIZE + FLV_TAG_SIZE );
+ tmp = (uint8_t *) realloc( rtmp_packet->body->body,
+ rtmp_packet->body->length_body +
+ FLV_TAG_PREVIOUS_TAG_SIZE + FLV_TAG_SIZE );
+ if( !tmp ) return;
+ rtmp_packet->body->body = tmp;
memmove( rtmp_packet->body->body + FLV_TAG_PREVIOUS_TAG_SIZE + FLV_TAG_SIZE,
- rtmp_packet->body->body, rtmp_packet->body->length_body );
+ rtmp_packet->body->body, rtmp_packet->body->length_body );
/* Insert tag */
p_thread->flv_tag_previous_tag_size = hton32( p_thread->flv_tag_previous_tag_size );
More information about the vlc-devel
mailing list