Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
ffmpeg
Project
Project
Details
Activity
Releases
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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Stefan Westerfeld
ffmpeg
Commits
c0eee893
Commit
c0eee893
authored
Apr 13, 2011
by
Kostya Shishkov
Committed by
Luca Barbato
Apr 15, 2011
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
make av_dup_packet() more cautious on allocation failures
Signed-off-by:
Luca Barbato
<
lu_zero@gentoo.org
>
parent
2d8591c2
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
7 deletions
+19
-7
avpacket.c
libavcodec/avpacket.c
+19
-7
No files found.
libavcodec/avpacket.c
View file @
c0eee893
...
...
@@ -100,19 +100,19 @@ int av_grow_packet(AVPacket *pkt, int grow_by)
return
0
;
}
#define DUP_DATA(dst, size, padding) \
#define DUP_DATA(dst, s
rc, s
ize, padding) \
do { \
void *data; \
if (padding) { \
if ((unsigned)(size) > (unsigned)(size) + FF_INPUT_BUFFER_PADDING_SIZE) \
return AVERROR(ENOMEM)
; \
goto failed_alloc
; \
data = av_malloc(size + FF_INPUT_BUFFER_PADDING_SIZE); \
} else { \
data = av_malloc(size); \
} \
if (!data) \
return AVERROR(ENOMEM)
; \
memcpy(data,
dst
, size); \
goto failed_alloc
; \
memcpy(data,
src
, size); \
if (padding) \
memset((uint8_t*)data + size, 0, FF_INPUT_BUFFER_PADDING_SIZE); \
dst = data; \
...
...
@@ -120,20 +120,32 @@ int av_grow_packet(AVPacket *pkt, int grow_by)
int
av_dup_packet
(
AVPacket
*
pkt
)
{
AVPacket
tmp_pkt
;
if
(((
pkt
->
destruct
==
av_destruct_packet_nofree
)
||
(
pkt
->
destruct
==
NULL
))
&&
pkt
->
data
)
{
DUP_DATA
(
pkt
->
data
,
pkt
->
size
,
1
);
tmp_pkt
=
*
pkt
;
pkt
->
data
=
NULL
;
pkt
->
side_data
=
NULL
;
DUP_DATA
(
pkt
->
data
,
tmp_pkt
.
data
,
pkt
->
size
,
1
);
pkt
->
destruct
=
av_destruct_packet
;
if
(
pkt
->
side_data_elems
)
{
int
i
;
DUP_DATA
(
pkt
->
side_data
,
pkt
->
side_data_elems
*
sizeof
(
*
pkt
->
side_data
),
0
);
DUP_DATA
(
pkt
->
side_data
,
tmp_pkt
.
side_data
,
pkt
->
side_data_elems
*
sizeof
(
*
pkt
->
side_data
),
0
);
memset
(
pkt
->
side_data
,
0
,
pkt
->
side_data_elems
*
sizeof
(
*
pkt
->
side_data
));
for
(
i
=
0
;
i
<
pkt
->
side_data_elems
;
i
++
)
{
DUP_DATA
(
pkt
->
side_data
[
i
].
data
,
pkt
->
side_data
[
i
].
size
,
1
);
DUP_DATA
(
pkt
->
side_data
[
i
].
data
,
tmp_pkt
.
side_data
[
i
].
data
,
pkt
->
side_data
[
i
].
size
,
1
);
}
}
}
return
0
;
failed_alloc:
av_destruct_packet
(
pkt
);
return
AVERROR
(
ENOMEM
);
}
void
av_free_packet
(
AVPacket
*
pkt
)
...
...
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