Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc-2-2
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-2-2
Commits
31b5fbdb
Commit
31b5fbdb
authored
May 20, 2012
by
Pierre Ynard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
lua: fix memory and object leak and reset locale on error path
parent
bc87dd70
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
11 deletions
+17
-11
modules/lua/libs/equalizer.c
modules/lua/libs/equalizer.c
+17
-11
No files found.
modules/lua/libs/equalizer.c
View file @
31b5fbdb
...
@@ -133,7 +133,7 @@ Band 9: 16 kHz
...
@@ -133,7 +133,7 @@ Band 9: 16 kHz
*****************************************************************************/
*****************************************************************************/
static
int
vlclua_equalizer_get
(
lua_State
*
L
)
static
int
vlclua_equalizer_get
(
lua_State
*
L
)
{
{
int
bands
=
9
;
const
unsigned
bands
=
10
;
input_thread_t
*
p_input
=
vlclua_get_input_internal
(
L
);
input_thread_t
*
p_input
=
vlclua_get_input_internal
(
L
);
if
(
!
p_input
)
if
(
!
p_input
)
return
0
;
return
0
;
...
@@ -142,7 +142,6 @@ static int vlclua_equalizer_get( lua_State *L )
...
@@ -142,7 +142,6 @@ static int vlclua_equalizer_get( lua_State *L )
if
(
!
p_aout
)
if
(
!
p_aout
)
return
0
;
return
0
;
float
level
=
0
;
char
*
psz_af
=
var_GetNonEmptyString
(
p_aout
,
"audio-filter"
);
char
*
psz_af
=
var_GetNonEmptyString
(
p_aout
,
"audio-filter"
);
if
(
!
psz_af
||
strstr
(
psz_af
,
"equalizer"
)
==
NULL
)
if
(
!
psz_af
||
strstr
(
psz_af
,
"equalizer"
)
==
NULL
)
{
{
...
@@ -159,24 +158,31 @@ static int vlclua_equalizer_get( lua_State *L )
...
@@ -159,24 +158,31 @@ static int vlclua_equalizer_get( lua_State *L )
vlc_object_release
(
p_aout
);
vlc_object_release
(
p_aout
);
return
0
;
return
0
;
}
}
bool
error
=
false
;
locale_t
loc
=
newlocale
(
LC_NUMERIC_MASK
,
"C"
,
NULL
);
locale_t
loc
=
newlocale
(
LC_NUMERIC_MASK
,
"C"
,
NULL
);
locale_t
oldloc
=
uselocale
(
loc
);
locale_t
oldloc
=
uselocale
(
loc
);
int
i
=
0
;
char
*
str
;
lua_newtable
(
L
);
lua_newtable
(
L
);
while
(
bands
>=
0
)
for
(
unsigned
i
=
0
;
i
<
bands
;
i
++
)
{
{
level
=
strtof
(
psz_bands
,
&
psz_bands
);
float
level
=
strtof
(
psz_bands
,
&
psz_bands
);
bands
--
;
char
*
str
;
if
(
asprintf
(
&
str
,
"%f"
,
level
)
==
-
1
)
if
(
asprintf
(
&
str
,
"%f"
,
level
)
==
-
1
)
return
0
;
{
error
=
true
;
break
;
}
lua_pushstring
(
L
,
str
);
lua_pushstring
(
L
,
str
);
free
(
str
);
free
(
str
);
if
(
asprintf
(
&
str
,
"band id=
\"
%d
\"
"
,
i
++
)
==
-
1
)
if
(
asprintf
(
&
str
,
"band id=
\"
%u
\"
"
,
i
)
==
-
1
)
return
0
;
{
error
=
true
;
break
;
}
lua_setfield
(
L
,
-
2
,
str
);
lua_setfield
(
L
,
-
2
,
str
);
free
(
str
);
free
(
str
);
}
}
free
(
psz_bands_origin
);
free
(
psz_bands_origin
);
if
(
loc
!=
(
locale_t
)
0
)
if
(
loc
!=
(
locale_t
)
0
)
{
{
...
@@ -184,7 +190,7 @@ static int vlclua_equalizer_get( lua_State *L )
...
@@ -184,7 +190,7 @@ static int vlclua_equalizer_get( lua_State *L )
freelocale
(
loc
);
freelocale
(
loc
);
}
}
vlc_object_release
(
p_aout
);
vlc_object_release
(
p_aout
);
return
1
;
return
error
?
0
:
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