Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
videolan
vlc
Commits
f972ae13
Commit
f972ae13
authored
Mar 21, 2011
by
Rémi Duraffort
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
vlm: fix memory leaks.
parent
51b83519
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
15 deletions
+26
-15
src/control/vlm.c
src/control/vlm.c
+26
-15
No files found.
src/control/vlm.c
View file @
f972ae13
...
...
@@ -227,6 +227,7 @@ static char* recurse_answer( vlm_message_t *p_answer, const char* psz_delim,
char
*
psz_childdelim
=
NULL
;
char
*
psz_nametag
=
NULL
;
char
*
psz_response
=
strdup
(
""
);
char
*
psz_tmp
;
int
i_success
=
0
;
int
i
;
vlm_message_t
*
aw_child
,
**
paw_child
;
...
...
@@ -248,9 +249,11 @@ static char* recurse_answer( vlm_message_t *p_answer, const char* psz_delim,
/* Append name of child node, if not in a list */
if
(
!
i_list
)
{
i_success
=
asprintf
(
&
psz_
response
,
"%s
\"
%s
\"
: "
,
i_success
=
asprintf
(
&
psz_
tmp
,
"%s
\"
%s
\"
: "
,
psz_response
,
aw_child
->
psz_name
);
if
(
i_success
==
-
1
)
break
;
free
(
psz_response
);
psz_response
=
psz_tmp
;
}
/* If child node has children, */
...
...
@@ -278,24 +281,28 @@ static char* recurse_answer( vlm_message_t *p_answer, const char* psz_delim,
strcmp
(
aw_child
->
psz_name
,
"inputs"
)
==
0
||
strcmp
(
aw_child
->
psz_name
,
"options"
)
==
0
)
{
i_success
=
asprintf
(
&
psz_response
,
"%s[%s%s%s]%c%s"
,
psz_response
,
psz_childdelim
,
recurse_answer
(
aw_child
,
psz_childdelim
,
1
),
char
*
psz_recurse
=
recurse_answer
(
aw_child
,
psz_childdelim
,
1
),
i_success
=
asprintf
(
&
psz_tmp
,
"%s[%s%s%s]%c%s"
,
psz_response
,
psz_childdelim
,
psz_recurse
,
psz_delim
,
c_comma
,
psz_delim
);
free
(
psz_recurse
);
if
(
i_success
==
-
1
)
break
;
free
(
psz_response
);
psz_response
=
psz_tmp
;
}
/* Not a list, so format the child as a JSON object and
* recurse through the child's children
*/
else
{
i_success
=
asprintf
(
&
psz_response
,
"%s{%s%s%s%s}%c%s"
,
char
*
psz_recurse
=
recurse_answer
(
aw_child
,
psz_childdelim
,
0
),
i_success
=
asprintf
(
&
psz_tmp
,
"%s{%s%s%s%s}%c%s"
,
psz_response
,
psz_childdelim
,
psz_nametag
,
recurse_answer
(
aw_child
,
psz_childdelim
,
0
),
psz_delim
,
c_comma
,
psz_delim
);
psz_recurse
,
psz_delim
,
c_comma
,
psz_delim
);
free
(
psz_recurse
);
if
(
i_success
==
-
1
)
break
;
free
(
psz_response
);
psz_response
=
psz_tmp
;
}
}
/* Otherwise - when no children are present - the node is a
...
...
@@ -307,18 +314,21 @@ static char* recurse_answer( vlm_message_t *p_answer, const char* psz_delim,
if
(
aw_child
->
psz_value
==
NULL
||
strcmp
(
aw_child
->
psz_value
,
"(null)"
)
==
0
)
{
i_success
=
asprintf
(
&
psz_
response
,
"%snull%c%s"
,
i_success
=
asprintf
(
&
psz_
tmp
,
"%snull%c%s"
,
psz_response
,
c_comma
,
psz_delim
);
if
(
i_success
==
-
1
)
break
;
if
(
i_success
==
-
1
)
break
;
free
(
psz_response
);
psz_response
=
psz_tmp
;
}
/* Otherwise print the value in quotation marks */
else
{
i_success
=
asprintf
(
&
psz_
response
,
"%s
\"
%s
\"
%c%s"
,
i_success
=
asprintf
(
&
psz_
tmp
,
"%s
\"
%s
\"
%c%s"
,
psz_response
,
aw_child
->
psz_value
,
c_comma
,
psz_delim
);
if
(
i_success
==
-
1
)
break
;
free
(
psz_response
);
psz_response
=
psz_tmp
;
}
}
/* getting next child */
...
...
@@ -373,12 +383,13 @@ const char* libvlc_vlm_show_media( libvlc_instance_t *p_instance,
psz_delimiter
=
"
\n
"
;
i_list
=
1
;
}
if
(
asprintf
(
&
psz_response
,
psz_fmt
,
recurse_answer
(
answer
,
psz_delimiter
,
i_list
)
)
==
-
1
)
char
*
psz_tmp
=
recurse_answer
(
answer
,
psz_delimiter
,
i_list
);
if
(
asprintf
(
&
psz_response
,
psz_fmt
,
psz_tmp
)
==
-
1
)
{
libvlc_printerr
(
"Out of memory"
);
psz_response
=
NULL
;
}
free
(
psz_tmp
);
}
free
(
psz_message
);
return
(
psz_response
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment