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
27576416
Commit
27576416
authored
May 15, 2023
by
Edward Thomson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tests: only copy when `ptr` is non-NULL
Avoid passing a `NULL` ptr to `memcpy` -- that's UB (even if size is 0)
parent
8e5281c8
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
0 deletions
+4
-0
tests/clar/clar_libgit2_alloc.c
+4
-0
No files found.
tests/clar/clar_libgit2_alloc.c
View file @
27576416
...
@@ -73,13 +73,17 @@ static void *cl__realloc(void *ptr, size_t size, const char *file, int line)
...
@@ -73,13 +73,17 @@ static void *cl__realloc(void *ptr, size_t size, const char *file, int line)
if
(
p
)
if
(
p
)
memcpy
(
&
copybytes
,
p
-
sizeof
(
size_t
),
sizeof
(
size_t
));
memcpy
(
&
copybytes
,
p
-
sizeof
(
size_t
),
sizeof
(
size_t
));
if
(
copybytes
>
size
)
if
(
copybytes
>
size
)
copybytes
=
size
;
copybytes
=
size
;
if
((
new
=
cl__malloc
(
size
,
file
,
line
))
==
NULL
)
if
((
new
=
cl__malloc
(
size
,
file
,
line
))
==
NULL
)
goto
out
;
goto
out
;
if
(
p
)
{
memcpy
(
new
,
p
,
copybytes
);
memcpy
(
new
,
p
,
copybytes
);
cl__free
(
p
);
cl__free
(
p
);
}
out:
out:
return
new
;
return
new
;
...
...
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