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
ee9794ed
Commit
ee9794ed
authored
Apr 24, 2013
by
Stefano Sabatini
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
lavu/mem: fix potential int overflow and crash in av_dynarray_add()
Also extend documentation accordingly.
parent
c773adee
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
2 deletions
+14
-2
mem.c
libavutil/mem.c
+12
-2
mem.h
libavutil/mem.h
+2
-0
No files found.
libavutil/mem.c
View file @
ee9794ed
...
...
@@ -249,15 +249,25 @@ void av_dynarray_add(void *tab_ptr, int *nb_ptr, void *elem)
nb
=
*
nb_ptr
;
tab
=
*
(
intptr_t
**
)
tab_ptr
;
if
((
nb
&
(
nb
-
1
))
==
0
)
{
if
(
nb
==
0
)
if
(
nb
==
0
)
{
nb_alloc
=
1
;
else
}
else
{
if
(
nb
>
INT_MAX
/
(
2
*
sizeof
(
intptr_t
)))
goto
fail
;
nb_alloc
=
nb
*
2
;
}
tab
=
av_realloc
(
tab
,
nb_alloc
*
sizeof
(
intptr_t
));
if
(
!
tab
)
goto
fail
;
*
(
intptr_t
**
)
tab_ptr
=
tab
;
}
tab
[
nb
++
]
=
(
intptr_t
)
elem
;
*
nb_ptr
=
nb
;
return
;
fail
:
av_freep
(
tab_ptr
);
*
nb_ptr
=
0
;
}
static
void
fill16
(
uint8_t
*
dst
,
int
len
)
...
...
libavutil/mem.h
View file @
ee9794ed
...
...
@@ -209,6 +209,8 @@ void av_freep(void *ptr);
* In case of success, the pointer to the array is updated in order to
* point to the new grown array, and the number pointed to by nb_ptr
* is incremented.
* In case of failure, the array is freed, *tab_ptr is set to NULL and
* *nb_ptr is set to 0.
*
* @param tab_ptr pointer to the array to grow
* @param nb_ptr pointer to the number of elements in the array
...
...
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