[mpd] Fix crash-on-exit because evconnlistener_free() doesn't ignore NULL pointers (issue #430)

This commit is contained in:
ejurgensen 2017-10-30 23:05:18 +01:00
parent b7f5070ad3
commit 04dc5956ed
1 changed files with 10 additions and 4 deletions

View File

@ -4988,7 +4988,10 @@ int mpd_init(void)
if (http_port > 0)
evhttp_free(evhttpd);
evhttp_fail:
// Note evconnlistener_free segfaults if you give it a null pointer, so we need the if
if (mpd_listener)
evconnlistener_free(mpd_listener);
if (mpd_listener6)
evconnlistener_free(mpd_listener6);
connew_fail:
commands_base_free(cmdbase);
@ -5036,7 +5039,10 @@ void mpd_deinit(void)
if (http_port > 0)
evhttp_free(evhttpd);
// Note evconnlistener_free segfaults if you give it a null pointer, so we need the if
if (mpd_listener)
evconnlistener_free(mpd_listener);
if (mpd_listener6)
evconnlistener_free(mpd_listener6);
// Free event base (should free events too)