[-] Misc housekeeping (minor memleaks, invalid free's)

This commit is contained in:
ejurgensen 2017-02-12 01:19:56 +01:00
parent 3896f61d06
commit 26c22144fc
7 changed files with 24 additions and 14 deletions

View File

@ -226,6 +226,7 @@ commands_base_new(struct event_base *evbase, command_exit_cb exit_cb)
int int
commands_base_free(struct commands_base *cmdbase) commands_base_free(struct commands_base *cmdbase)
{ {
event_free(cmdbase->command_event);
close(cmdbase->command_pipe[0]); close(cmdbase->command_pipe[0]);
close(cmdbase->command_pipe[1]); close(cmdbase->command_pipe[1]);
free(cmdbase); free(cmdbase);

View File

@ -142,7 +142,7 @@ static struct event *exitev;
static struct evhttp *evhttpd; static struct evhttp *evhttpd;
static pthread_t tid_httpd; static pthread_t tid_httpd;
static char *allow_origin; static const char *allow_origin;
static int httpd_port; static int httpd_port;
#ifdef HAVE_LIBEVENT2_OLD #ifdef HAVE_LIBEVENT2_OLD
@ -936,11 +936,11 @@ static void
serve_file(struct evhttp_request *req, char *uri) serve_file(struct evhttp_request *req, char *uri)
{ {
const char *host; const char *host;
const char *passwd;
char *ext; char *ext;
char path[PATH_MAX]; char path[PATH_MAX];
char *deref; char *deref;
char *ctype; char *ctype;
char *passwd;
struct evbuffer *evbuf; struct evbuffer *evbuf;
struct evkeyvalq *headers; struct evkeyvalq *headers;
struct stat sb; struct stat sb;
@ -1311,7 +1311,7 @@ httpd_fixup_uri(struct evhttp_request *req)
static const char *http_reply_401 = "<html><head><title>401 Unauthorized</title></head><body>Authorization required</body></html>"; static const char *http_reply_401 = "<html><head><title>401 Unauthorized</title></head><body>Authorization required</body></html>";
int int
httpd_basic_auth(struct evhttp_request *req, char *user, char *passwd, char *realm) httpd_basic_auth(struct evhttp_request *req, const char *user, const char *passwd, const char *realm)
{ {
struct evbuffer *evbuf; struct evbuffer *evbuf;
struct evkeyvalq *headers; struct evkeyvalq *headers;

View File

@ -56,7 +56,7 @@ char *
httpd_fixup_uri(struct evhttp_request *req); httpd_fixup_uri(struct evhttp_request *req);
int int
httpd_basic_auth(struct evhttp_request *req, char *user, char *passwd, char *realm); httpd_basic_auth(struct evhttp_request *req, const char *user, const char *passwd, const char *realm);
int int
httpd_init(void); httpd_init(void);

View File

@ -519,18 +519,21 @@ pipe_watch_update(void *arg, int *retval)
pipelist_remove(&pipelist, pipe); pipelist_remove(&pipelist, pipe);
} }
for (pipe = pipelist; pipe; pipe = pipe->next) for (pipe = pipelist; pipe; pipe = next)
{ {
next = pipe->next;
count++; count++;
if (count > PIPE_MAX_WATCH) if (count > PIPE_MAX_WATCH)
{ {
DPRINTF(E_LOG, L_PLAYER, "Max open pipes reached, will not watch %s\n", pipe->path); DPRINTF(E_LOG, L_PLAYER, "Max open pipes reached (%d), will not watch '%s'\n", PIPE_MAX_WATCH, pipe->path);
break; pipelist_remove(&pipelist, pipe);
continue;
} }
DPRINTF(E_DBG, L_PLAYER, "Pipe watch added: '%s'\n", pipe->path); DPRINTF(E_DBG, L_PLAYER, "Pipe watch added: '%s'\n", pipe->path);
watch_add(pipe); watch_add(pipe);
pipelist_add(&pipe_watch_list, pipe); pipelist_add(&pipe_watch_list, pipe); // Changes pipe->next
} }
*retval = 0; *retval = 0;

View File

@ -1017,7 +1017,7 @@ alsa_init(void)
} }
device->id = 0; device->id = 0;
device->name = nickname; device->name = strdup(nickname);
device->type = OUTPUT_TYPE_ALSA; device->type = OUTPUT_TYPE_ALSA;
device->type_name = outputs_name(device->type); device->type_name = outputs_name(device->type);
device->advertised = 1; device->advertised = 1;

View File

@ -266,7 +266,7 @@ dummy_init(void)
} }
device->id = 0; device->id = 0;
device->name = nickname; device->name = strdup(nickname);
device->type = OUTPUT_TYPE_DUMMY; device->type = OUTPUT_TYPE_DUMMY;
device->type_name = outputs_name(device->type); device->type_name = outputs_name(device->type);
device->advertised = 1; device->advertised = 1;

View File

@ -2064,6 +2064,9 @@ playback_start_id(void *arg, int *retval)
} }
cmd_state = playback_start_item(queue_item, retval); cmd_state = playback_start_item(queue_item, retval);
free_queue_item(queue_item, 0);
return cmd_state; return cmd_state;
} }
@ -2084,6 +2087,9 @@ playback_start(void *arg, int *retval)
} }
cmd_state = playback_start_item(queue_item, retval); cmd_state = playback_start_item(queue_item, retval);
free_queue_item(queue_item, 0);
return cmd_state; return cmd_state;
} }
@ -3208,6 +3214,10 @@ player_deinit(void)
timer_delete(pb_timer); timer_delete(pb_timer);
#endif #endif
input_deinit();
outputs_deinit();
player_exit = 1; player_exit = 1;
commands_base_destroy(cmdbase); commands_base_destroy(cmdbase);
@ -3219,10 +3229,6 @@ player_deinit(void)
return; return;
} }
input_deinit();
outputs_deinit();
free(history); free(history);
event_base_free(evbase_player); event_base_free(evbase_player);