[vlc-commits] sap: memory leak

Rémi Denis-Courmont git at videolan.org
Tue Apr 22 22:51:12 CEST 2014


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Tue Apr 22 23:51:01 2014 +0300| [7f7437c52157ca043d623b18be53e9ad2dd8060e] | committer: Rémi Denis-Courmont

sap: memory leak

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

 modules/services_discovery/sap.c |   16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/modules/services_discovery/sap.c b/modules/services_discovery/sap.c
index 5376106..29933fd 100644
--- a/modules/services_discovery/sap.c
+++ b/modules/services_discovery/sap.c
@@ -750,12 +750,12 @@ static int ParseSAP( services_discovery_t *p_sd, const uint8_t *buf,
         if (strcmp (psz_sdp, "application/sdp"))
         {
             msg_Dbg (p_sd, "unsupported content type: %s", psz_sdp);
-            return VLC_EGENERIC;
+            goto error;
         }
 
         // skips content type
         if (len <= clen)
-            return VLC_EGENERIC;
+            goto error;
 
         len -= clen;
         psz_sdp += clen;
@@ -765,7 +765,7 @@ static int ParseSAP( services_discovery_t *p_sd, const uint8_t *buf,
     p_sdp = ParseSDP( VLC_OBJECT(p_sd), psz_sdp );
 
     if( p_sdp == NULL )
-        return VLC_EGENERIC;
+        goto error;
 
     p_sdp->psz_sdp = psz_sdp;
 
@@ -785,7 +785,7 @@ static int ParseSAP( services_discovery_t *p_sd, const uint8_t *buf,
     if( p_sdp->psz_uri == NULL )
     {
         FreeSDP( p_sdp );
-        return VLC_EGENERIC;
+        goto error;
     }
 
     for( i = 0 ; i< p_sd->p_sys->i_announces ; i++ )
@@ -817,15 +817,19 @@ static int ParseSAP( services_discovery_t *p_sd, const uint8_t *buf,
                 p_announce->i_period = ( p_announce->i_period * (p_announce->i_period_trust-1) + (now - p_announce->i_last) ) / p_announce->i_period_trust;
                 p_announce->i_last = now;
             }
-            FreeSDP( p_sdp ); p_sdp = NULL;
+            FreeSDP( p_sdp );
+            free (decomp);
             return VLC_SUCCESS;
         }
     }
 
     CreateAnnounce( p_sd, i_source, i_hash, p_sdp );
 
-    FREENULL (decomp);
+    free (decomp);
     return VLC_SUCCESS;
+error:
+    free (decomp);
+    return VLC_EGENERIC;
 }
 
 sap_announce_t *CreateAnnounce( services_discovery_t *p_sd, uint32_t *i_source, uint16_t i_hash,



More information about the vlc-commits mailing list