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
85a205b4
Commit
85a205b4
authored
Jun 06, 2015
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
adpcm: do not abuse fmt_in.p_extra, fix double free
parent
a3d0339d
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
8 deletions
+11
-8
modules/codec/adpcm.c
modules/codec/adpcm.c
+11
-8
No files found.
modules/codec/adpcm.c
View file @
85a205b4
...
@@ -72,6 +72,7 @@ struct decoder_sys_t
...
@@ -72,6 +72,7 @@ struct decoder_sys_t
size_t
i_samplesperblock
;
size_t
i_samplesperblock
;
date_t
end_date
;
date_t
end_date
;
int16_t
*
prev
;
};
};
static
void
DecodeAdpcmMs
(
decoder_t
*
,
int16_t
*
,
uint8_t
*
);
static
void
DecodeAdpcmMs
(
decoder_t
*
,
int16_t
*
,
uint8_t
*
);
...
@@ -164,10 +165,12 @@ static int OpenDecoder( vlc_object_t *p_this )
...
@@ -164,10 +165,12 @@ static int OpenDecoder( vlc_object_t *p_this )
}
}
/* Allocate the memory needed to store the decoder's structure */
/* Allocate the memory needed to store the decoder's structure */
if
(
(
p_dec
->
p_sys
=
p_sys
=
p_sys
=
malloc
(
sizeof
(
*
p_sys
));
(
decoder_sys_t
*
)
malloc
(
sizeof
(
decoder_sys_t
))
)
==
NULL
)
if
(
unlikely
(
p_sys
==
NULL
)
)
return
VLC_ENOMEM
;
return
VLC_ENOMEM
;
p_sys
->
prev
=
NULL
;
switch
(
p_dec
->
fmt_in
.
i_codec
)
switch
(
p_dec
->
fmt_in
.
i_codec
)
{
{
case
VLC_FOURCC
(
'i'
,
'm'
,
'a'
,
'4'
):
/* IMA ADPCM */
case
VLC_FOURCC
(
'i'
,
'm'
,
'a'
,
'4'
):
/* IMA ADPCM */
...
@@ -187,9 +190,9 @@ static int OpenDecoder( vlc_object_t *p_this )
...
@@ -187,9 +190,9 @@ static int OpenDecoder( vlc_object_t *p_this )
break
;
break
;
case
VLC_FOURCC
(
'X'
,
'A'
,
'J'
,
0
):
/* EA ADPCM */
case
VLC_FOURCC
(
'X'
,
'A'
,
'J'
,
0
):
/* EA ADPCM */
p_sys
->
codec
=
ADPCM_EA
;
p_sys
->
codec
=
ADPCM_EA
;
p_
dec
->
fmt_in
.
p_extra
=
calloc
(
2
*
p_dec
->
fmt_in
.
audio
.
i_channels
,
p_
sys
->
prev
=
calloc
(
2
*
p_dec
->
fmt_in
.
audio
.
i_channels
,
sizeof
(
int16_t
)
);
sizeof
(
int16_t
)
);
if
(
p_dec
->
fmt_in
.
p_extra
==
NULL
)
if
(
unlikely
(
p_sys
->
prev
==
NULL
)
)
{
{
free
(
p_sys
);
free
(
p_sys
);
return
VLC_ENOMEM
;
return
VLC_ENOMEM
;
...
@@ -245,6 +248,7 @@ static int OpenDecoder( vlc_object_t *p_this )
...
@@ -245,6 +248,7 @@ static int OpenDecoder( vlc_object_t *p_this )
p_dec
->
fmt_in
.
audio
.
i_bitspersample
,
p_sys
->
i_block
,
p_dec
->
fmt_in
.
audio
.
i_bitspersample
,
p_sys
->
i_block
,
p_sys
->
i_samplesperblock
);
p_sys
->
i_samplesperblock
);
p_dec
->
p_sys
=
p_sys
;
p_dec
->
fmt_out
.
i_cat
=
AUDIO_ES
;
p_dec
->
fmt_out
.
i_cat
=
AUDIO_ES
;
p_dec
->
fmt_out
.
i_codec
=
VLC_CODEC_S16N
;
p_dec
->
fmt_out
.
i_codec
=
VLC_CODEC_S16N
;
p_dec
->
fmt_out
.
audio
.
i_rate
=
p_dec
->
fmt_in
.
audio
.
i_rate
;
p_dec
->
fmt_out
.
audio
.
i_rate
=
p_dec
->
fmt_in
.
audio
.
i_rate
;
...
@@ -349,8 +353,7 @@ static void CloseDecoder( vlc_object_t *p_this )
...
@@ -349,8 +353,7 @@ static void CloseDecoder( vlc_object_t *p_this )
decoder_t
*
p_dec
=
(
decoder_t
*
)
p_this
;
decoder_t
*
p_dec
=
(
decoder_t
*
)
p_this
;
decoder_sys_t
*
p_sys
=
p_dec
->
p_sys
;
decoder_sys_t
*
p_sys
=
p_dec
->
p_sys
;
if
(
p_sys
->
codec
==
ADPCM_EA
)
free
(
p_sys
->
prev
);
free
(
p_dec
->
fmt_in
.
p_extra
);
free
(
p_sys
);
free
(
p_sys
);
}
}
...
@@ -741,7 +744,7 @@ static void DecodeAdpcmEA( decoder_t *p_dec, int16_t *p_sample,
...
@@ -741,7 +744,7 @@ static void DecodeAdpcmEA( decoder_t *p_dec, int16_t *p_sample,
unsigned
chans
=
p_dec
->
fmt_in
.
audio
.
i_channels
;
unsigned
chans
=
p_dec
->
fmt_in
.
audio
.
i_channels
;
const
uint8_t
*
p_end
=
&
p_buffer
[
p_sys
->
i_block
];
const
uint8_t
*
p_end
=
&
p_buffer
[
p_sys
->
i_block
];
int16_t
*
prev
=
(
int16_t
*
)
p_dec
->
fmt_in
.
p_extra
;
int16_t
*
prev
=
p_sys
->
prev
;
int16_t
*
cur
=
prev
+
chans
;
int16_t
*
cur
=
prev
+
chans
;
for
(
unsigned
c
=
0
;
c
<
chans
;
c
++
)
for
(
unsigned
c
=
0
;
c
<
chans
;
c
++
)
...
...
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