Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
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
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
06c8a9ed
Commit
06c8a9ed
authored
Oct 14, 2008
by
Eric Wong
Committed by
Max Kellermann
Oct 14, 2008
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
{dir,song}vec: fix off-by-one errors in {dir,song}vec_delete
Found by Valgrind while looking for another bug... Hmm.. I should really just make this code generic since they're duplicated...
parent
f71ac4d4
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
10 deletions
+9
-10
dirvec.c
src/dirvec.c
+3
-3
songvec.c
src/songvec.c
+6
-7
No files found.
src/dirvec.c
View file @
06c8a9ed
...
...
@@ -37,9 +37,9 @@ struct directory *dirvec_find(const struct dirvec *dv, const char *path)
int
dirvec_delete
(
struct
dirvec
*
dv
,
struct
directory
*
del
)
{
in
t
i
;
size_
t
i
;
for
(
i
=
dv
->
nr
;
--
i
>=
0
;
)
{
for
(
i
=
0
;
i
<
dv
->
nr
;
++
i
)
{
if
(
dv
->
base
[
i
]
!=
del
)
continue
;
/* we _don't_ call directory_free() here */
...
...
@@ -48,7 +48,7 @@ int dirvec_delete(struct dirvec *dv, struct directory *del)
dv
->
base
=
NULL
;
}
else
{
memmove
(
&
dv
->
base
[
i
],
&
dv
->
base
[
i
+
1
],
(
dv
->
nr
-
i
+
1
)
*
sizeof
(
struct
directory
*
));
(
dv
->
nr
-
i
)
*
sizeof
(
struct
directory
*
));
dv
->
base
=
xrealloc
(
dv
->
base
,
dv_size
(
dv
));
}
return
i
;
...
...
src/songvec.c
View file @
06c8a9ed
...
...
@@ -47,28 +47,27 @@ songvec_find(const struct songvec *sv, const char *url)
int
songvec_delete
(
struct
songvec
*
sv
,
const
struct
song
*
del
)
{
in
t
i
;
size_
t
i
;
pthread_mutex_lock
(
&
nr_lock
);
for
(
i
=
sv
->
nr
;
--
i
>=
0
;
)
{
for
(
i
=
0
;
i
<
sv
->
nr
;
++
i
)
{
if
(
sv
->
base
[
i
]
!=
del
)
continue
;
/* we _don't_ call song_free() here */
if
(
!--
sv
->
nr
)
{
pthread_mutex_unlock
(
&
nr_lock
);
free
(
sv
->
base
);
sv
->
base
=
NULL
;
return
i
;
}
else
{
memmove
(
&
sv
->
base
[
i
],
&
sv
->
base
[
i
+
1
],
(
sv
->
nr
-
i
+
1
)
*
sizeof
(
struct
song
*
));
(
sv
->
nr
-
i
)
*
sizeof
(
struct
song
*
));
sv
->
base
=
xrealloc
(
sv
->
base
,
sv_size
(
sv
));
}
break
;
pthread_mutex_unlock
(
&
nr_lock
);
return
i
;
}
pthread_mutex_unlock
(
&
nr_lock
);
return
i
;
return
-
1
;
/* not found */
}
void
...
...
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