Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
git2
Overview
Overview
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
lvzhengyang
git2
Commits
19001ca7
Commit
19001ca7
authored
Nov 02, 2016
by
Patrick Steinhardt
Committed by
GitHub
Nov 02, 2016
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3976 from pks-t/pks/pqueue-null-deref
pqueue: resolve possible NULL pointer dereference
parents
41ad9ebf
95fa3880
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
2 deletions
+25
-2
src/pqueue.c
+3
-2
tests/core/pqueue.c
+22
-0
No files found.
src/pqueue.c
View file @
19001ca7
...
...
@@ -86,8 +86,9 @@ int git_pqueue_insert(git_pqueue *pq, void *item)
if
((
pq
->
flags
&
GIT_PQUEUE_FIXED_SIZE
)
!=
0
&&
pq
->
length
>=
pq
->
_alloc_size
)
{
/* skip this item if below min item in heap */
if
(
pq
->
_cmp
(
item
,
git_vector_get
(
pq
,
0
))
<=
0
)
/* skip this item if below min item in heap or if
* we do not have a comparison function */
if
(
!
pq
->
_cmp
||
pq
->
_cmp
(
item
,
git_vector_get
(
pq
,
0
))
<=
0
)
return
0
;
/* otherwise remove the min item before inserting new */
(
void
)
git_pqueue_pop
(
pq
);
...
...
tests/core/pqueue.c
View file @
19001ca7
...
...
@@ -93,7 +93,29 @@ void test_core_pqueue__max_heap_size(void)
cl_assert_equal_i
(
0
,
git_pqueue_size
(
&
pq
));
git_pqueue_free
(
&
pq
);
}
void
test_core_pqueue__max_heap_size_without_comparison
(
void
)
{
git_pqueue
pq
;
int
i
,
vals
[
100
]
=
{
0
};
cl_git_pass
(
git_pqueue_init
(
&
pq
,
GIT_PQUEUE_FIXED_SIZE
,
50
,
NULL
));
for
(
i
=
0
;
i
<
100
;
++
i
)
cl_git_pass
(
git_pqueue_insert
(
&
pq
,
&
vals
[
i
]));
cl_assert_equal_i
(
50
,
git_pqueue_size
(
&
pq
));
/* As we have no comparison function, we cannot make any
* actual assumptions about which entries are part of the
* pqueue */
for
(
i
=
0
;
i
<
50
;
++
i
)
cl_assert
(
git_pqueue_pop
(
&
pq
));
cl_assert_equal_i
(
0
,
git_pqueue_size
(
&
pq
));
git_pqueue_free
(
&
pq
);
}
static
int
cmp_ints_like_commit_time
(
const
void
*
a
,
const
void
*
b
)
...
...
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