From 8be5e5b7cb19fd052d86a3c90a75c268a4d7d133 Mon Sep 17 00:00:00 2001 From: Tristan Matthews Date: Fri, 11 Jul 2014 14:49:55 -0400 Subject: [PATCH 1/2] fix some memory allocation issues --- hdmv/hdmv.c | 4 ++-- libmpegts.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/hdmv/hdmv.c b/hdmv/hdmv.c index d0027cf..bcab275 100644 --- a/hdmv/hdmv.c +++ b/hdmv/hdmv.c @@ -31,7 +31,7 @@ int ts_setup_hdmv_lpcm_stream( ts_writer_t *w, int pid, int num_channels, int sa return -1; } - stream->lpcm_ctx = calloc( 1, sizeof(stream->lpcm_ctx) ); + stream->lpcm_ctx = calloc( 1, sizeof(*stream->lpcm_ctx) ); if( !stream->lpcm_ctx ) return -1; @@ -44,7 +44,7 @@ int ts_setup_hdmv_lpcm_stream( ts_writer_t *w, int pid, int num_channels, int sa int ts_setup_dtcp( ts_writer_t *w, uint8_t byte_1, uint8_t byte_2 ) { - w->dtcp_ctx = calloc( 1, sizeof(w->dtcp_ctx) ); + w->dtcp_ctx = calloc( 1, sizeof(*w->dtcp_ctx) ); if( !w->dtcp_ctx ) return -1; diff --git a/libmpegts.c b/libmpegts.c index e4cfea8..4f90b62 100644 --- a/libmpegts.c +++ b/libmpegts.c @@ -1532,7 +1532,7 @@ int ts_write_frames( ts_writer_t *w, ts_frame_t *frames, int num_frames, uint8_t if( num_frames ) { - ts_int_pes_t **tmp = realloc( w->buffered_frames, (w->num_buffered_frames+num_frames) * sizeof(w->buffered_frames) ); + ts_int_pes_t **tmp = realloc( w->buffered_frames, (w->num_buffered_frames+num_frames) * sizeof(w->buffered_frames[0]) ); if( !tmp ) { fprintf( stderr, "Malloc failed\n" ); From c711c30be198968b2822792d540fe5d206e34681 Mon Sep 17 00:00:00 2001 From: Tristan Matthews Date: Fri, 11 Jul 2014 14:47:59 -0400 Subject: [PATCH 2/2] fix memleak --- libmpegts.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libmpegts.c b/libmpegts.c index 4f90b62..e560912 100644 --- a/libmpegts.c +++ b/libmpegts.c @@ -985,6 +985,7 @@ int ts_setup_transport_stream( ts_writer_t *w, ts_main_t *params ) if( !cur_stream->stream_type ) { fprintf( stderr, "Unsupported Stream Format\n" ); + free( cur_stream ); return -1; }