Commit 7681a9b5 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

Fix some memleaks

parent fd2c85f5
...@@ -215,7 +215,7 @@ VLC_EXPORT(session_descriptor_t*,sout_AnnounceRegisterSDP, (sout_instance_t *, c ...@@ -215,7 +215,7 @@ VLC_EXPORT(session_descriptor_t*,sout_AnnounceRegisterSDP, (sout_instance_t *, c
VLC_EXPORT( int, sout_AnnounceUnRegister, (sout_instance_t *,session_descriptor_t* ) ); VLC_EXPORT( int, sout_AnnounceUnRegister, (sout_instance_t *,session_descriptor_t* ) );
VLC_EXPORT(session_descriptor_t*,sout_AnnounceSessionCreate, (vlc_object_t *obj, const char *cfgpref) ); VLC_EXPORT(session_descriptor_t*,sout_AnnounceSessionCreate, (vlc_object_t *obj, const char *cfgpref) );
VLC_EXPORT(int, sout_SessionSetMedia, (vlc_object_t *obj, session_descriptor_t *, char *, char *, int, char *, int) ); VLC_EXPORT(int, sout_SessionSetMedia, (vlc_object_t *obj, session_descriptor_t *, const char *, const char *, int, const char *, int) );
VLC_EXPORT(void, sout_AnnounceSessionDestroy, (session_descriptor_t *) ); VLC_EXPORT(void, sout_AnnounceSessionDestroy, (session_descriptor_t *) );
VLC_EXPORT(announce_method_t*, sout_SAPMethod, (void) ); VLC_EXPORT(announce_method_t*, sout_SAPMethod, (void) );
VLC_EXPORT(void, sout_MethodRelease, (announce_method_t *) ); VLC_EXPORT(void, sout_MethodRelease, (announce_method_t *) );
......
...@@ -390,9 +390,6 @@ static int Open( vlc_object_t *p_this ) ...@@ -390,9 +390,6 @@ static int Open( vlc_object_t *p_this )
{ {
msg_Err (p_access, "SAP announces not supported for access %s", msg_Err (p_access, "SAP announces not supported for access %s",
psz_access); psz_access);
free (fmt);
free (src);
free (dst);
goto nosap; goto nosap;
} }
...@@ -403,8 +400,12 @@ static int Open( vlc_object_t *p_this ) ...@@ -403,8 +400,12 @@ static int Open( vlc_object_t *p_this )
sout_AnnounceRegister( p_sout, p_session, p_method ); sout_AnnounceRegister( p_sout, p_session, p_method );
p_stream->p_sys->p_session = p_session; p_stream->p_sys->p_session = p_session;
sout_MethodRelease (p_method); sout_MethodRelease (p_method);
}
nosap: nosap:
free (fmt);
free (src);
free (dst);
}
p_stream->pf_add = Add; p_stream->pf_add = Add;
p_stream->pf_del = Del; p_stream->pf_del = Del;
......
...@@ -193,28 +193,36 @@ session_descriptor_t * sout_AnnounceSessionCreate (vlc_object_t *obj, ...@@ -193,28 +193,36 @@ session_descriptor_t * sout_AnnounceSessionCreate (vlc_object_t *obj,
} }
int sout_SessionSetMedia (vlc_object_t *obj, session_descriptor_t *p_session, int sout_SessionSetMedia (vlc_object_t *obj, session_descriptor_t *p_session,
char *fmt, char *src, int sport, const char *fmt, const char *src, int sport,
char *dst, int dport) const char *dst, int dport)
{ {
p_session->sdpformat = fmt; if ((p_session->sdpformat = strdup (fmt)) == NULL)
return VLC_ENOMEM;
/* GRUIK. We should not convert back-and-forth from string to numbers */ /* GRUIK. We should not convert back-and-forth from string to numbers */
struct addrinfo *res; struct addrinfo *res;
if (vlc_getaddrinfo (obj, dst, dport, NULL, &res) == 0) if (vlc_getaddrinfo (obj, dst, dport, NULL, &res) == 0)
{ {
if (res->ai_addrlen <= sizeof (p_session->addr)) if (res->ai_addrlen > sizeof (p_session->addr))
goto oflow;
memcpy (&p_session->addr, res->ai_addr, memcpy (&p_session->addr, res->ai_addr,
p_session->addrlen = res->ai_addrlen); p_session->addrlen = res->ai_addrlen);
vlc_freeaddrinfo (res); vlc_freeaddrinfo (res);
} }
if (vlc_getaddrinfo (obj, src, sport, NULL, &res) == 0) if (vlc_getaddrinfo (obj, src, sport, NULL, &res) == 0)
{ {
if (res->ai_addrlen <= sizeof (p_session->orig)) if (res->ai_addrlen > sizeof (p_session->orig))
goto oflow;
memcpy (&p_session->orig, res->ai_addr, memcpy (&p_session->orig, res->ai_addr,
p_session->origlen = res->ai_addrlen); p_session->origlen = res->ai_addrlen);
vlc_freeaddrinfo (res); vlc_freeaddrinfo (res);
} }
return 0; return 0;
oflow:
vlc_freeaddrinfo (res);
return VLC_ENOMEM;
} }
/** /**
...@@ -231,6 +239,7 @@ void sout_AnnounceSessionDestroy( session_descriptor_t *p_session ) ...@@ -231,6 +239,7 @@ void sout_AnnounceSessionDestroy( session_descriptor_t *p_session )
free (p_session->psz_group); free (p_session->psz_group);
free (p_session->psz_sdp); free (p_session->psz_sdp);
free (p_session->description); free (p_session->description);
free (p_session->sdpformat);
free (p_session->url); free (p_session->url);
free (p_session->email); free (p_session->email);
free (p_session->phone); free (p_session->phone);
......
...@@ -21,7 +21,8 @@ ...@@ -21,7 +21,8 @@
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. ***************************************************************************/ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
***************************************************************************/
#include <vlc_sout.h> #include <vlc_sout.h>
#include <vlc_network.h> #include <vlc_network.h>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment