Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc-1.1
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-1.1
Commits
98c78b8b
Commit
98c78b8b
authored
Feb 08, 2010
by
Jean-Philippe André
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Lua SD: fix obvious leaks
+ Add missing include
parent
12b8ebac
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
13 deletions
+20
-13
modules/misc/lua/libs/sd.c
modules/misc/lua/libs/sd.c
+20
-13
No files found.
modules/misc/lua/libs/sd.c
View file @
98c78b8b
...
@@ -36,6 +36,7 @@
...
@@ -36,6 +36,7 @@
#include <vlc_common.h>
#include <vlc_common.h>
#include <vlc_services_discovery.h>
#include <vlc_services_discovery.h>
#include <vlc_playlist.h>
#include <vlc_playlist.h>
#include <vlc_charset.h>
#include <lua.h>
/* Low level lua C API */
#include <lua.h>
/* Low level lua C API */
#include <lauxlib.h>
/* Higher level C API */
#include <lauxlib.h>
/* Higher level C API */
...
@@ -117,8 +118,9 @@ static int vlclua_sd_add_node( lua_State *L )
...
@@ -117,8 +118,9 @@ static int vlclua_sd_add_node( lua_State *L )
lua_getfield
(
L
,
-
1
,
"title"
);
lua_getfield
(
L
,
-
1
,
"title"
);
if
(
lua_isstring
(
L
,
-
1
)
)
if
(
lua_isstring
(
L
,
-
1
)
)
{
{
input_item_t
*
p_input
=
input_item_New
(
p_sd
,
"vlc://nop"
,
input_item_t
*
p_input
=
input_item_New
(
p_sd
,
strdup
(
lua_tostring
(
L
,
-
1
)
)
);
"vlc://nop"
,
lua_tostring
(
L
,
-
1
)
);
lua_pop
(
L
,
1
);
lua_pop
(
L
,
1
);
lua_getfield
(
L
,
-
1
,
"arturl"
);
lua_getfield
(
L
,
-
1
,
"arturl"
);
if
(
lua_isstring
(
L
,
-
1
)
)
if
(
lua_isstring
(
L
,
-
1
)
)
...
@@ -126,6 +128,7 @@ static int vlclua_sd_add_node( lua_State *L )
...
@@ -126,6 +128,7 @@ static int vlclua_sd_add_node( lua_State *L )
char
*
psz_value
=
strdup
(
lua_tostring
(
L
,
-
1
)
);
char
*
psz_value
=
strdup
(
lua_tostring
(
L
,
-
1
)
);
EnsureUTF8
(
psz_value
);
EnsureUTF8
(
psz_value
);
msg_Dbg
(
p_sd
,
"ArtURL: %s"
,
psz_value
);
msg_Dbg
(
p_sd
,
"ArtURL: %s"
,
psz_value
);
/** @todo Ask for art download if not local file */
input_item_SetArtURL
(
p_input
,
psz_value
);
input_item_SetArtURL
(
p_input
,
psz_value
);
free
(
psz_value
);
free
(
psz_value
);
}
}
...
@@ -157,13 +160,14 @@ static int vlclua_sd_add_item( lua_State *L )
...
@@ -157,13 +160,14 @@ static int vlclua_sd_add_item( lua_State *L )
lua_getfield
(
L
,
-
1
,
"url"
);
lua_getfield
(
L
,
-
1
,
"url"
);
if
(
lua_isstring
(
L
,
-
1
)
)
if
(
lua_isstring
(
L
,
-
1
)
)
{
{
input_item_t
*
p_input
=
input_item_New
(
p_sd
,
char
*
psz_url
=
strdup
(
lua_tostring
(
L
,
-
1
)
);
strdup
(
lua_tostring
(
L
,
-
1
)
),
strdup
(
lua_tostring
(
L
,
-
1
)
)
);
lua_pop
(
L
,
1
);
lua_pop
(
L
,
1
);
input_item_t
*
p_input
=
input_item_New
(
p_sd
,
psz_url
,
psz_url
);
free
(
psz_url
);
vlclua_read_meta_data
(
p_sd
,
L
,
p_input
);
vlclua_read_meta_data
(
p_sd
,
L
,
p_input
);
/* This one is to be tested... */
/* This one is to be tested... */
vlclua_read_custom_meta_data
(
p_sd
,
L
,
p_input
);
vlclua_read_custom_meta_data
(
p_sd
,
L
,
p_input
);
/* The duration is given in seconds, convert to microseconds */
lua_getfield
(
L
,
-
1
,
"duration"
);
lua_getfield
(
L
,
-
1
,
"duration"
);
if
(
lua_isnumber
(
L
,
-
1
)
)
if
(
lua_isnumber
(
L
,
-
1
)
)
input_item_SetDuration
(
p_input
,
(
lua_tonumber
(
L
,
-
1
)
*
1e6
)
);
input_item_SetDuration
(
p_input
,
(
lua_tonumber
(
L
,
-
1
)
*
1e6
)
);
...
@@ -197,6 +201,8 @@ static int vlclua_sd_remove_item( lua_State *L )
...
@@ -197,6 +201,8 @@ static int vlclua_sd_remove_item( lua_State *L )
input_item_t
**
pp_input
=
luaL_checkudata
(
L
,
-
1
,
"input_item_t"
);
input_item_t
**
pp_input
=
luaL_checkudata
(
L
,
-
1
,
"input_item_t"
);
if
(
*
pp_input
)
if
(
*
pp_input
)
services_discovery_RemoveItem
(
p_sd
,
*
pp_input
);
services_discovery_RemoveItem
(
p_sd
,
*
pp_input
);
/* Make sure we won't try to remove it again */
*
pp_input
=
NULL
;
}
}
return
1
;
return
1
;
}
}
...
@@ -212,11 +218,11 @@ static int vlclua_node_add_subitem( lua_State *L )
...
@@ -212,11 +218,11 @@ static int vlclua_node_add_subitem( lua_State *L )
lua_getfield
(
L
,
-
1
,
"url"
);
lua_getfield
(
L
,
-
1
,
"url"
);
if
(
lua_isstring
(
L
,
-
1
)
)
if
(
lua_isstring
(
L
,
-
1
)
)
{
{
input_item_node_t
*
p_input_node
=
input_item_node_Create
(
*
pp_node
);
char
*
url
=
strdup
(
lua_tostring
(
L
,
-
1
)
);
input_item_t
*
p_input
=
input_item_New
(
p_sd
,
strdup
(
lua_tostring
(
L
,
-
1
)
),
strdup
(
lua_tostring
(
L
,
-
1
)
)
);
lua_pop
(
L
,
1
);
lua_pop
(
L
,
1
);
input_item_node_t
*
p_input_node
=
input_item_node_Create
(
*
pp_node
);
input_item_t
*
p_input
=
input_item_New
(
p_sd
,
url
,
url
);
free
(
url
);
vlclua_read_meta_data
(
p_sd
,
L
,
p_input
);
vlclua_read_meta_data
(
p_sd
,
L
,
p_input
);
/* This one is to be tested... */
/* This one is to be tested... */
vlclua_read_custom_meta_data
(
p_sd
,
L
,
p_input
);
vlclua_read_custom_meta_data
(
p_sd
,
L
,
p_input
);
...
@@ -258,11 +264,12 @@ static int vlclua_node_add_node( lua_State *L )
...
@@ -258,11 +264,12 @@ static int vlclua_node_add_node( lua_State *L )
lua_getfield
(
L
,
-
1
,
"title"
);
lua_getfield
(
L
,
-
1
,
"title"
);
if
(
lua_isstring
(
L
,
-
1
)
)
if
(
lua_isstring
(
L
,
-
1
)
)
{
{
input_item_node_t
*
p_input_node
=
input_item_node_Create
(
*
pp_node
);
char
*
name
=
strdup
(
lua_tostring
(
L
,
-
1
)
);
input_item_t
*
p_input
=
input_item_New
(
p_sd
,
"vlc://nop"
,
strdup
(
lua_tostring
(
L
,
-
1
)
)
);
lua_pop
(
L
,
1
);
lua_pop
(
L
,
1
);
input_item_node_t
*
p_input_node
=
input_item_node_Create
(
*
pp_node
);
input_item_t
*
p_input
=
input_item_New
(
p_sd
,
"vlc://nop"
,
name
);
free
(
name
);
lua_getfield
(
L
,
-
1
,
"arturl"
);
lua_getfield
(
L
,
-
1
,
"arturl"
);
if
(
lua_isstring
(
L
,
-
1
)
)
if
(
lua_isstring
(
L
,
-
1
)
)
{
{
...
...
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