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
c4085fbf
Commit
c4085fbf
authored
May 23, 2013
by
Ben Straub
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1601 from Merovius/bugfix_shorten
Bugfix: Return NULL in push_leaf, when trie is full
parents
6828bf26
06c070b5
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
42 additions
and
1 deletions
+42
-1
src/oid.c
+3
-1
tests-clar/object/raw/short.c
+39
-0
No files found.
src/oid.c
View file @
c4085fbf
...
...
@@ -269,8 +269,10 @@ static trie_node *push_leaf(git_oid_shorten *os, node_index idx, int push_at, co
idx_leaf
=
(
node_index
)
os
->
node_count
++
;
if
(
os
->
node_count
==
SHRT_MAX
)
if
(
os
->
node_count
==
SHRT_MAX
)
{
os
->
full
=
1
;
return
NULL
;
}
node
=
&
os
->
nodes
[
idx
];
node
->
children
[
push_at
]
=
-
idx_leaf
;
...
...
tests-clar/object/raw/short.c
View file @
c4085fbf
...
...
@@ -92,3 +92,42 @@ void test_object_raw_short__oid_shortener_stresstest_git_oid_shorten(void)
#undef MAX_OIDS
}
void
test_object_raw_short__oid_shortener_too_much_oids
(
void
)
{
/* The magic number of oids at which an oid_shortener will fail.
* This was experimentally established. */
#define MAX_OIDS 24556
git_oid_shorten
*
os
;
char
number_buffer
[
16
];
git_oid
oid
;
size_t
i
;
int
min_len
=
0
;
os
=
git_oid_shorten_new
(
0
);
cl_assert
(
os
!=
NULL
);
for
(
i
=
0
;
i
<
MAX_OIDS
;
++
i
)
{
char
*
oid_text
;
p_snprintf
(
number_buffer
,
16
,
"%u"
,
(
unsigned
int
)
i
);
git_hash_buf
(
&
oid
,
number_buffer
,
strlen
(
number_buffer
));
oid_text
=
git__malloc
(
GIT_OID_HEXSZ
+
1
);
git_oid_fmt
(
oid_text
,
&
oid
);
oid_text
[
GIT_OID_HEXSZ
]
=
0
;
min_len
=
git_oid_shorten_add
(
os
,
oid_text
);
/* All but the last oid should give a non-negative min_len. At the
* last oid, git_oid_shorten_add should fail, returning a negative
* value */
if
(
i
<
MAX_OIDS
-
1
)
cl_assert
(
min_len
>=
0
);
else
cl_assert
(
min_len
<
0
);
}
git_oid_shorten_free
(
os
);
}
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