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
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(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(announce_method_t*, sout_SAPMethod, (void) );
VLC_EXPORT(void, sout_MethodRelease, (announce_method_t *) );
......
......@@ -390,9 +390,6 @@ static int Open( vlc_object_t *p_this )
{
msg_Err (p_access, "SAP announces not supported for access %s",
psz_access);
free (fmt);
free (src);
free (dst);
goto nosap;
}
......@@ -403,8 +400,12 @@ static int Open( vlc_object_t *p_this )
sout_AnnounceRegister( p_sout, p_session, p_method );
p_stream->p_sys->p_session = p_session;
sout_MethodRelease (p_method);
}
nosap:
free (fmt);
free (src);
free (dst);
}
p_stream->pf_add = Add;
p_stream->pf_del = Del;
......
......@@ -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,
char *fmt, char *src, int sport,
char *dst, int dport)
const char *fmt, const char *src, int sport,
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 */
struct addrinfo *res;
if (vlc_getaddrinfo (obj, dst, dport, NULL, &res) == 0)
{
if (res->ai_addrlen <= sizeof (p_session->addr))
memcpy (&p_session->addr, res->ai_addr,
p_session->addrlen = res->ai_addrlen);
if (res->ai_addrlen > sizeof (p_session->addr))
goto oflow;
memcpy (&p_session->addr, res->ai_addr,
p_session->addrlen = res->ai_addrlen);
vlc_freeaddrinfo (res);
}
if (vlc_getaddrinfo (obj, src, sport, NULL, &res) == 0)
{
if (res->ai_addrlen <= sizeof (p_session->orig))
memcpy (&p_session->orig, res->ai_addr,
p_session->origlen = res->ai_addrlen);
if (res->ai_addrlen > sizeof (p_session->orig))
goto oflow;
memcpy (&p_session->orig, res->ai_addr,
p_session->origlen = res->ai_addrlen);
vlc_freeaddrinfo (res);
}
return 0;
oflow:
vlc_freeaddrinfo (res);
return VLC_ENOMEM;
}
/**
......@@ -231,6 +239,7 @@ void sout_AnnounceSessionDestroy( session_descriptor_t *p_session )
free (p_session->psz_group);
free (p_session->psz_sdp);
free (p_session->description);
free (p_session->sdpformat);
free (p_session->url);
free (p_session->email);
free (p_session->phone);
......
......@@ -21,7 +21,8 @@
*
* You should have received a copy of the GNU General Public License
* 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_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