Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Xiph.Org
Icecast-IceS
Commits
d5333af8
Commit
d5333af8
authored
Jul 06, 2003
by
Karl Heyes
Browse files
fix potential segv on updated ices2 playlist
svn path=/trunk/ices/; revision=5078
parent
20a86537
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/playlist_basic.c
View file @
d5333af8
/* playlist_basic.c
* - Simple built-in unscripted playlist
*
* $Id: playlist_basic.c,v 1.1
0
2003/0
3/22 02:27:55
karl Exp $
* $Id: playlist_basic.c,v 1.1
1
2003/0
7/06 14:50:19
karl Exp $
*
* Copyright (c) 2001 Michael Smith <msmith@labyrinth.net.au>
*
...
...
@@ -46,22 +46,15 @@ static void shuffle(char **buf, int len)
buf
[
n
-
1
]
=
temp
;
--
n
;
}
LOG_DEBUG0
(
"Playlist has been shuffled"
);
}
static
int
load_playlist
(
basic_playlist
*
data
)
{
FILE
*
file
;
struct
stat
st
;
char
buf
[
1024
];
int
buflen
;
if
(
stat
(
data
->
file
,
&
st
))
{
LOG_ERROR2
(
"Couldn't stat file
\"
%s
\"
: %s"
,
data
->
file
,
strerror
(
errno
));
return
-
1
;
}
data
->
mtime
=
st
.
st_mtime
;
file
=
fopen
(
data
->
file
,
"rb"
);
if
(
file
==
NULL
)
...
...
@@ -71,7 +64,6 @@ static int load_playlist(basic_playlist *data)
return
-
1
;
}
if
(
data
->
pl
)
{
int
i
;
...
...
@@ -111,7 +103,6 @@ static int load_playlist(basic_playlist *data)
if
(
data
->
random
)
shuffle
(
data
->
pl
,
data
->
len
);
return
0
;
}
...
...
@@ -134,42 +125,61 @@ void playlist_basic_clear(void *data)
char
*
playlist_basic_get_next_filename
(
void
*
data
)
{
basic_playlist
*
pl
=
(
basic_playlist
*
)
data
;
char
*
ptr
=
NULL
,
*
dest
=
NULL
;
int
reload_playlist
=
0
;
struct
stat
st
;
if
(
!
pl
->
pl
)
return
NULL
;
if
(
stat
(
pl
->
file
,
&
st
))
if
(
stat
(
pl
->
file
,
&
st
))
{
LOG_ERROR2
(
"Couldn't stat file
\"
%s
\"
: %s"
,
pl
->
file
,
strerror
(
errno
));
return
NULL
;
}
if
(
st
.
st_mtime
!=
pl
->
mtime
)
if
(
pl
->
pl
)
{
if
(
st
.
st_mtime
!=
pl
->
mtime
)
{
reload_playlist
=
1
;
LOG_INFO1
(
"Reloading playlist after file
\"
%s
\"
changed"
,
pl
->
file
);
pl
->
mtime
=
st
.
st_mtime
;
}
}
else
{
LOG_INFO1
(
"Loading playlist from file
\"
%s
\"
"
,
pl
->
file
);
reload_playlist
=
1
;
pl
->
mtime
=
st
.
st_mtime
;
}
if
(
reload_playlist
)
{
LOG_INFO1
(
"Reloading playlist after file
\"
%s
\"
changed"
,
pl
->
file
);
if
(
load_playlist
(
pl
)
<
0
)
if
(
load_playlist
(
pl
)
<
0
)
return
NULL
;
if
(
pl
->
restartafterreread
)
if
(
pl
->
restartafterreread
)
pl
->
pos
=
0
;
}
if
(
pl
->
pos
<
pl
->
len
)
{
return
pl
->
pl
[
pl
->
pos
++
];
}
else
if
(
!
pl
->
once
)
if
(
pl
->
pos
>=
pl
->
len
)
/* reached the end of the potentially updated list */
{
if
(
pl
->
random
)
if
(
pl
->
once
)
return
NULL
;
pl
->
pos
=
0
;
if
(
pl
->
random
)
shuffle
(
pl
->
pl
,
pl
->
len
);
pl
->
pos
=
1
;
return
pl
->
pl
[
0
];
}
else
return
NULL
;
/* Once-through mode, at end */
ptr
=
pl
->
pl
[
pl
->
pos
++
];
if
((
dest
=
malloc
(
strlen
(
ptr
)))
==
NULL
)
return
NULL
;
strcpy
(
dest
,
ptr
);
return
dest
;
}
void
playlist_basic_free_filename
(
void
*
data
,
char
*
fn
)
{
free
(
fn
);
}
int
playlist_basic_initialise
(
module_param_t
*
params
,
playlist_state_t
*
pl
)
...
...
@@ -212,6 +222,6 @@ int playlist_basic_initialise(module_param_t *params, playlist_state_t *pl)
return
-
1
;
}
return
load_playlist
(
data
)
;
return
0
;
}
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