Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
F
ffmpeg.wasm-core
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Linshizhi
ffmpeg.wasm-core
Commits
211a185c
Commit
211a185c
authored
Sep 13, 2013
by
Paul B Mahol
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avfilter/avfilter: check allocation failure in ff_insert_pad()
Signed-off-by:
Paul B Mahol
<
onemda@gmail.com
>
parent
5ab7b3b9
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
8 deletions
+22
-8
avfilter.c
libavfilter/avfilter.c
+14
-3
internal.h
libavfilter/internal.h
+8
-5
No files found.
libavfilter/avfilter.c
View file @
211a185c
...
...
@@ -94,16 +94,25 @@ void ff_command_queue_pop(AVFilterContext *filter)
av_free
(
c
);
}
void
ff_insert_pad
(
unsigned
idx
,
unsigned
*
count
,
size_t
padidx_off
,
int
ff_insert_pad
(
unsigned
idx
,
unsigned
*
count
,
size_t
padidx_off
,
AVFilterPad
**
pads
,
AVFilterLink
***
links
,
AVFilterPad
*
newpad
)
{
AVFilterLink
**
newlinks
;
AVFilterPad
*
newpads
;
unsigned
i
;
idx
=
FFMIN
(
idx
,
*
count
);
*
pads
=
av_realloc
(
*
pads
,
sizeof
(
AVFilterPad
)
*
(
*
count
+
1
));
*
links
=
av_realloc
(
*
links
,
sizeof
(
AVFilterLink
*
)
*
(
*
count
+
1
));
newpads
=
av_realloc_array
(
*
pads
,
*
count
+
1
,
sizeof
(
AVFilterPad
));
newlinks
=
av_realloc_array
(
*
links
,
*
count
+
1
,
sizeof
(
AVFilterLink
*
));
if
(
newpads
)
*
pads
=
newpads
;
if
(
newlinks
)
*
links
=
newlinks
;
if
(
!
newpads
||
!
newlinks
)
return
AVERROR
(
ENOMEM
);
memmove
(
*
pads
+
idx
+
1
,
*
pads
+
idx
,
sizeof
(
AVFilterPad
)
*
(
*
count
-
idx
));
memmove
(
*
links
+
idx
+
1
,
*
links
+
idx
,
sizeof
(
AVFilterLink
*
)
*
(
*
count
-
idx
));
memcpy
(
*
pads
+
idx
,
newpad
,
sizeof
(
AVFilterPad
));
...
...
@@ -113,6 +122,8 @@ void ff_insert_pad(unsigned idx, unsigned *count, size_t padidx_off,
for
(
i
=
idx
+
1
;
i
<
*
count
;
i
++
)
if
(
*
links
[
i
])
(
*
(
unsigned
*
)((
uint8_t
*
)
*
links
[
i
]
+
padidx_off
))
++
;
return
0
;
}
int
avfilter_link
(
AVFilterContext
*
src
,
unsigned
srcpad
,
...
...
libavfilter/internal.h
View file @
211a185c
...
...
@@ -249,35 +249,38 @@ void ff_tlog_link(void *ctx, AVFilterLink *link, int end);
* @param pads Pointer to the pointer to the beginning of the list of pads
* @param links Pointer to the pointer to the beginning of the list of links
* @param newpad The new pad to add. A copy is made when adding.
* @return >= 0 in case of success, a negative AVERROR code on error
*/
void
ff_insert_pad
(
unsigned
idx
,
unsigned
*
count
,
size_t
padidx_off
,
int
ff_insert_pad
(
unsigned
idx
,
unsigned
*
count
,
size_t
padidx_off
,
AVFilterPad
**
pads
,
AVFilterLink
***
links
,
AVFilterPad
*
newpad
);
/** Insert a new input pad for the filter. */
static
inline
void
ff_insert_inpad
(
AVFilterContext
*
f
,
unsigned
index
,
static
inline
int
ff_insert_inpad
(
AVFilterContext
*
f
,
unsigned
index
,
AVFilterPad
*
p
)
{
ff_insert_pad
(
index
,
&
f
->
nb_inputs
,
offsetof
(
AVFilterLink
,
dstpad
),
int
ret
=
ff_insert_pad
(
index
,
&
f
->
nb_inputs
,
offsetof
(
AVFilterLink
,
dstpad
),
&
f
->
input_pads
,
&
f
->
inputs
,
p
);
#if FF_API_FOO_COUNT
FF_DISABLE_DEPRECATION_WARNINGS
f
->
input_count
=
f
->
nb_inputs
;
FF_ENABLE_DEPRECATION_WARNINGS
#endif
return
ret
;
}
/** Insert a new output pad for the filter. */
static
inline
void
ff_insert_outpad
(
AVFilterContext
*
f
,
unsigned
index
,
static
inline
int
ff_insert_outpad
(
AVFilterContext
*
f
,
unsigned
index
,
AVFilterPad
*
p
)
{
ff_insert_pad
(
index
,
&
f
->
nb_outputs
,
offsetof
(
AVFilterLink
,
srcpad
),
int
ret
=
ff_insert_pad
(
index
,
&
f
->
nb_outputs
,
offsetof
(
AVFilterLink
,
srcpad
),
&
f
->
output_pads
,
&
f
->
outputs
,
p
);
#if FF_API_FOO_COUNT
FF_DISABLE_DEPRECATION_WARNINGS
f
->
output_count
=
f
->
nb_outputs
;
FF_ENABLE_DEPRECATION_WARNINGS
#endif
return
ret
;
}
/**
...
...
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