[vlc-devel] commit: Fix memleaks (corner case). ( Rémi Duraffort )

git version control git at videolan.org
Thu Jul 3 22:53:20 CEST 2008


vlc | branch: master | Rémi Duraffort <ivoire at videolan.org> | Wed Jul  2 23:18:06 2008 +0200| [5cf39390c0d9a4c9ef2860746126f0bbad3370b6]

Fix memleaks (corner case).

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=5cf39390c0d9a4c9ef2860746126f0bbad3370b6
---

 modules/misc/rtsp.c       |   12 ++++++++++++
 modules/stream_out/rtsp.c |    2 ++
 2 files changed, 14 insertions(+), 0 deletions(-)

diff --git a/modules/misc/rtsp.c b/modules/misc/rtsp.c
index 463af33..ae7e277 100644
--- a/modules/misc/rtsp.c
+++ b/modules/misc/rtsp.c
@@ -492,7 +492,10 @@ static int MediaAddES( vod_t *p_vod, vod_media_t *p_media, es_format_t *p_fmt )
     /* TODO: update SDP, etc... */
     if( asprintf( &psz_urlc, "%s/trackID=%d",
               p_media->psz_rtsp_path, p_media->i_es ) < 0 )
+    {
+        free( p_es );
         return VLC_ENOMEM;
+    }
     msg_Dbg( p_vod, "  - ES %4.4s (%s)", (char *)&p_fmt->i_codec, psz_urlc );
 
     switch( p_fmt->i_codec )
@@ -583,11 +586,19 @@ static int MediaAddES( vod_t *p_vod, vod_media_t *p_media, es_format_t *p_fmt )
                 }
                 /* */
                 if( p_64_sps && p_64_pps )
+                {
                     if( asprintf( &p_es->psz_fmtp,
                                   "packetization-mode=1;profile-level-id=%s;"
                                   "sprop-parameter-sets=%s,%s;", hexa, p_64_sps,
                                   p_64_pps ) < 0 )
+                    {
+                        free( p_64_sps );
+                        free( p_64_pps );
+                        free( psz_urlc );
+                        free( p_es );
                         return VLC_ENOMEM;
+                    }
+                }
                 free( p_64_sps );
                 free( p_64_pps );
             }
@@ -649,6 +660,7 @@ static int MediaAddES( vod_t *p_vod, vod_media_t *p_media, es_format_t *p_fmt )
         default:
             msg_Err( p_vod, "cannot add this stream (unsupported "
                     "codec: %4.4s)", (char*)&p_fmt->i_codec );
+            free( psz_urlc );
             free( p_es );
             return VLC_EGENERIC;
     }
diff --git a/modules/stream_out/rtsp.c b/modules/stream_out/rtsp.c
index 412ef7c..30e3552 100644
--- a/modules/stream_out/rtsp.c
+++ b/modules/stream_out/rtsp.c
@@ -138,6 +138,8 @@ void RtspUnsetup( rtsp_stream_t *rtsp )
 
     free( rtsp->psz_path );
     vlc_mutex_destroy( &rtsp->lock );
+
+    free( rtsp );
 }
 
 




More information about the vlc-devel mailing list