1
0
mirror of https://gitlab.xiph.org/xiph/icecast-server.git synced 2024-12-04 14:46:30 -05:00

Fix: Handle case realloc() is used as free().

This (hopefully) corrects the usage of realloc() as free().
This patch is part of the series based on Denis Denisov's input.
This commit is contained in:
Philipp Schafft 2015-04-08 13:05:10 +00:00
parent 6605f4ddaa
commit 3d2ab9aec2

View File

@ -148,14 +148,12 @@ int fserve_client_waiting (void)
unsigned int i = 0;
/* only rebuild ufds if there are clients added/removed */
if (client_tree_changed)
{
if (client_tree_changed) {
struct pollfd *ufds_new = realloc(ufds, fserve_clients * sizeof(struct pollfd));
/* REVIEW: If we can not allocate new ufds, keep old ones for now. */
if (ufds_new) {
if (ufds_new || fserve_clients == 0) {
ufds = ufds_new;
client_tree_changed = 0;
ufds = ufds_new;
fclient = active_list;
while (fclient)
{
@ -167,15 +165,13 @@ int fserve_client_waiting (void)
}
}
}
if (!ufds)
{
if (!ufds) {
thread_spin_lock (&pending_lock);
run_fserv = 0;
thread_spin_unlock (&pending_lock);
return -1;
}
else if (poll(ufds, fserve_clients, 200) > 0)
{
} else if (poll(ufds, fserve_clients, 200) > 0) {
/* mark any clients that are ready */
fclient = active_list;
for (i=0; i<fserve_clients; i++)
@ -186,6 +182,7 @@ int fserve_client_waiting (void)
}
return 1;
}
return 0;
}
#else