Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
X
xvba-video
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
xvba-video
Commits
1c34ed63
Commit
1c34ed63
authored
Dec 09, 2011
by
Jean-Paul Saman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
safe handling of realloc()
parent
b167c3d8
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
6 deletions
+12
-6
src/utils.c
src/utils.c
+3
-3
src/xvba_subpic.c
src/xvba_subpic.c
+9
-3
No files found.
src/utils.c
View file @
1c34ed63
...
@@ -168,12 +168,12 @@ realloc_buffer(
...
@@ -168,12 +168,12 @@ realloc_buffer(
if
(
!
buffer_p
||
!
max_elements_p
)
if
(
!
buffer_p
||
!
max_elements_p
)
return
NULL
;
return
NULL
;
void
*
buffer
=
*
buffer_p
;
if
(
*
max_elements_p
>
num_elements
)
if
(
*
max_elements_p
>
num_elements
)
return
buffer
;
return
*
buffer_p
;
void
*
buffer
;
num_elements
+=
4
;
num_elements
+=
4
;
if
((
buffer
=
realloc
(
buffer
,
num_elements
*
element_size
))
==
NULL
)
{
if
((
buffer
=
realloc
(
*
buffer_p
,
num_elements
*
element_size
))
==
NULL
)
{
free
(
*
buffer_p
);
free
(
*
buffer_p
);
*
buffer_p
=
NULL
;
*
buffer_p
=
NULL
;
return
NULL
;
return
NULL
;
...
...
src/xvba_subpic.c
View file @
1c34ed63
...
@@ -54,7 +54,7 @@ subpicture_add_association(
...
@@ -54,7 +54,7 @@ subpicture_add_association(
)
)
{
{
SubpictureAssociationP
*
assocs
;
SubpictureAssociationP
*
assocs
;
assocs
=
realloc_buffer
(
&
obj_subpicture
->
assocs
,
assocs
=
realloc_buffer
(
(
void
**
)
&
obj_subpicture
->
assocs
,
&
obj_subpicture
->
assocs_count_max
,
&
obj_subpicture
->
assocs_count_max
,
1
+
obj_subpicture
->
assocs_count
,
1
+
obj_subpicture
->
assocs_count
,
sizeof
(
obj_subpicture
->
assocs
[
0
]));
sizeof
(
obj_subpicture
->
assocs
[
0
]));
...
@@ -94,8 +94,14 @@ subpicture_remove_association(
...
@@ -94,8 +94,14 @@ subpicture_remove_association(
unsigned
int
i
;
unsigned
int
i
;
for
(
i
=
0
;
i
<
obj_subpicture
->
assocs_count
;
i
++
)
{
for
(
i
=
0
;
i
<
obj_subpicture
->
assocs_count
;
i
++
)
{
if
(
obj_subpicture
->
assocs
[
i
]
==
assoc
)
if
(
obj_subpicture
->
assocs
[
i
]
==
assoc
)
{
return
subpicture_remove_association_at
(
obj_subpicture
,
i
);
/* Free association at 'index' */
SubpictureAssociationP
a
=
obj_subpicture
->
assocs
[
i
];
ASSERT
(
a
);
int
idx
=
subpicture_remove_association_at
(
obj_subpicture
,
i
);
free
(
a
);
return
idx
;
}
}
}
return
-
1
;
return
-
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