mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-05 13:29:57 -05:00
raop: Handle the reponse header memory allocation more sensibly.
In theory the callback called after reading headers could free our whole object, so we should not take it upon ourselves to free the headers after the call to the callback.
This commit is contained in:
parent
b75a4b437a
commit
8a00c00943
1 changed files with 26 additions and 28 deletions
|
|
@ -101,7 +101,8 @@ pa_rtsp_client* pa_rtsp_client_new(pa_mainloop_api *mainloop, const char* hostna
|
|||
|
||||
|
||||
void pa_rtsp_client_free(pa_rtsp_client* c) {
|
||||
if (c) {
|
||||
pa_assert(c);
|
||||
|
||||
if (c->sc)
|
||||
pa_socket_client_unref(c->sc);
|
||||
if (c->ioline)
|
||||
|
|
@ -120,7 +121,7 @@ void pa_rtsp_client_free(pa_rtsp_client* c) {
|
|||
if (c->response_headers)
|
||||
pa_headerlist_free(c->response_headers);
|
||||
pa_headerlist_free(c->headers);
|
||||
}
|
||||
|
||||
pa_xfree(c);
|
||||
}
|
||||
|
||||
|
|
@ -141,8 +142,6 @@ static void headers_read(pa_rtsp_client *c) {
|
|||
c->transport = pa_xstrdup(pa_headerlist_gets(c->response_headers, "Transport"));
|
||||
|
||||
if (!c->session || !c->transport) {
|
||||
pa_headerlist_free(c->response_headers);
|
||||
c->response_headers = NULL;
|
||||
pa_log("Invalid SETUP response.");
|
||||
return;
|
||||
}
|
||||
|
|
@ -160,8 +159,6 @@ static void headers_read(pa_rtsp_client *c) {
|
|||
}
|
||||
if (0 == c->rtp_port) {
|
||||
/* Error no server_port in response */
|
||||
pa_headerlist_free(c->response_headers);
|
||||
c->response_headers = NULL;
|
||||
pa_log("Invalid SETUP response (no port number).");
|
||||
return;
|
||||
}
|
||||
|
|
@ -169,9 +166,6 @@ static void headers_read(pa_rtsp_client *c) {
|
|||
|
||||
/* Call our callback */
|
||||
c->callback(c, c->state, c->response_headers, c->userdata);
|
||||
|
||||
pa_headerlist_free(c->response_headers);
|
||||
c->response_headers = NULL;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -201,7 +195,8 @@ static void line_callback(pa_ioline *line, const char *s, void *userdata) {
|
|||
}
|
||||
if (c->waiting && 0 == strcmp("RTSP/1.0 200 OK", s2)) {
|
||||
c->waiting = 0;
|
||||
pa_assert(!c->response_headers);
|
||||
if (c->response_headers)
|
||||
pa_headerlist_free(c->response_headers);
|
||||
c->response_headers = pa_headerlist_new();
|
||||
goto exit;
|
||||
}
|
||||
|
|
@ -353,9 +348,12 @@ void pa_rtsp_set_callback(pa_rtsp_client *c, pa_rtsp_cb_t callback, void *userda
|
|||
void pa_rtsp_disconnect(pa_rtsp_client *c) {
|
||||
pa_assert(c);
|
||||
|
||||
if (c->io)
|
||||
if (c->ioline)
|
||||
pa_ioline_close(c->ioline);
|
||||
else if (c->io)
|
||||
pa_iochannel_free(c->io);
|
||||
c->io = NULL;
|
||||
c->ioline = NULL;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue