Commit a69589d3 authored by Rémi Duraffort's avatar Rémi Duraffort

realrtsp: fix potential memleaks.

parent e7d54bc7
......@@ -115,16 +115,22 @@ static int filter(const char *in, const char *filter, char **out, size_t outlen)
static sdpplin_stream_t *sdpplin_parse_stream(char **data) {
sdpplin_stream_t *desc = malloc(sizeof(sdpplin_stream_t));
char *buf = malloc(BUFLEN);
char *decoded = malloc(BUFLEN);
int handled;
sdpplin_stream_t *desc;
char* buf = NULL;
char* decoded = NULL;
int handled;
if( !desc ) return NULL;
memset(desc, 0, sizeof(sdpplin_stream_t));
desc = calloc( 1, sizeof(sdpplin_stream_t) );
if( !desc )
return NULL;
if( !buf ) goto error;
if( !decoded ) goto error;
buf = malloc( BUFLEN );
if( !buf )
goto error;
decoded = malloc( BUFLEN );
if( !decoded )
goto error;
if (filter(*data, "m=", &buf, BUFLEN)) {
desc->id = strdup(buf);
......@@ -227,32 +233,36 @@ error:
return NULL;
}
sdpplin_t *sdpplin_parse(char *data) {
sdpplin_t *desc = malloc(sizeof(sdpplin_t));
sdpplin_stream_t *stream;
char *buf=NULL;
char *decoded=NULL;
int handled;
int len;
sdpplin_t *sdpplin_parse(char *data)
{
sdpplin_t* desc;
sdpplin_stream_t* stream;
char* buf;
char* decoded;
int handled;
int len;
if( !desc ) return NULL;
buf = malloc(BUFLEN);
if( !buf ) {
desc = calloc( 1, sizeof(sdpplin_t) );
if( !desc )
return NULL;
buf = malloc( BUFLEN );
if( !buf )
{
free( desc );
return NULL;
}
decoded = malloc(BUFLEN);
if( !decoded ) {
decoded = malloc( BUFLEN );
if( !decoded )
{
free( buf );
free( desc );
return NULL;
}
desc->stream = NULL;
memset(desc, 0, sizeof(sdpplin_t));
while (data && *data) {
handled=0;
......@@ -358,7 +368,8 @@ void sdpplin_free(sdpplin_t *description) {
free( description->stream[i] );
}
}
if( description->stream_count ) free( description->stream );
if( description->stream_count )
free( description->stream );
free( description->owner );
free( description->session_name );
......@@ -375,5 +386,5 @@ void sdpplin_free(sdpplin_t *description) {
free( description->asm_rule_book );
free( description->abstract );
free( description->range );
free(description);
free( description );
}
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