Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
L
lxc
Project
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
Chen Yisong
lxc
Commits
f1c64634
Unverified
Commit
f1c64634
authored
Jun 29, 2021
by
Wolfgang Bumiller
Committed by
GitHub
Jun 29, 2021
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3877 from tomasz-blaszczak-red/fix-crash-after-remove-from-array
remove_from_array() causes a crash
parents
5e3ec989
bc5f0449
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
3 deletions
+12
-3
lxccontainer.c
src/lxc/lxccontainer.c
+12
-3
No files found.
src/lxc/lxccontainer.c
View file @
f1c64634
...
@@ -2262,7 +2262,7 @@ static inline int container_cmp(struct lxc_container **first,
...
@@ -2262,7 +2262,7 @@ static inline int container_cmp(struct lxc_container **first,
static
bool
add_to_array
(
char
***
names
,
char
*
cname
,
int
pos
)
static
bool
add_to_array
(
char
***
names
,
char
*
cname
,
int
pos
)
{
{
char
**
newnames
=
realloc
(
*
names
,
(
pos
+
1
)
*
sizeof
(
char
*
));
char
**
newnames
=
(
char
**
)
realloc
(
*
names
,
(
pos
+
1
)
*
sizeof
(
char
*
));
if
(
!
newnames
)
{
if
(
!
newnames
)
{
ERROR
(
"Out of memory"
);
ERROR
(
"Out of memory"
);
return
false
;
return
false
;
...
@@ -2320,7 +2320,16 @@ static bool remove_from_array(char ***names, char *cname, int size)
...
@@ -2320,7 +2320,16 @@ static bool remove_from_array(char ***names, char *cname, int size)
{
{
char
**
result
=
get_from_array
(
names
,
cname
,
size
);
char
**
result
=
get_from_array
(
names
,
cname
,
size
);
if
(
result
!=
NULL
)
{
if
(
result
!=
NULL
)
{
free
(
result
);
size_t
i
=
result
-
*
names
;
free
(
*
result
);
memmove
(
*
names
+
i
,
*
names
+
i
+
1
,
(
size
-
i
-
1
)
*
sizeof
(
char
*
));
char
**
newnames
=
(
char
**
)
realloc
(
*
names
,
(
size
-
1
)
*
sizeof
(
char
*
));
if
(
!
newnames
)
{
ERROR
(
"Out of memory"
);
return
true
;
}
*
names
=
newnames
;
return
true
;
return
true
;
}
}
...
@@ -5659,7 +5668,7 @@ int list_all_containers(const char *lxcpath, char ***nret,
...
@@ -5659,7 +5668,7 @@ int list_all_containers(const char *lxcpath, char ***nret,
{
{
int
i
,
ret
,
active_cnt
,
ct_cnt
,
ct_list_cnt
;
int
i
,
ret
,
active_cnt
,
ct_cnt
,
ct_list_cnt
;
char
**
active_name
;
char
**
active_name
;
char
**
ct_name
;
char
**
ct_name
=
NULL
;
struct
lxc_container
**
ct_list
=
NULL
;
struct
lxc_container
**
ct_list
=
NULL
;
ct_cnt
=
list_defined_containers
(
lxcpath
,
&
ct_name
,
NULL
);
ct_cnt
=
list_defined_containers
(
lxcpath
,
&
ct_name
,
NULL
);
...
...
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