Free HTTP headers and post data memory in disconnect and DNS failure callback (#1403)
This commit is contained in:
parent
cc2fee5ec0
commit
b21b3e08aa
|
@ -233,6 +233,22 @@ static void ICACHE_FLASH_ATTR http_connect_callback( void * arg )
|
|||
HTTPCLIENT_DEBUG( "Sending request header\n" );
|
||||
}
|
||||
|
||||
static void http_free_req( request_args_t * req)
|
||||
{
|
||||
if (req->buffer) {
|
||||
os_free( req->buffer );
|
||||
}
|
||||
if (req->post_data) {
|
||||
os_free( req->post_data );
|
||||
}
|
||||
if (req->headers) {
|
||||
os_free( req->headers );
|
||||
}
|
||||
os_free( req->hostname );
|
||||
os_free( req->method );
|
||||
os_free( req->path );
|
||||
os_free( req );
|
||||
}
|
||||
|
||||
static void ICACHE_FLASH_ATTR http_disconnect_callback( void * arg )
|
||||
{
|
||||
|
@ -301,13 +317,7 @@ static void ICACHE_FLASH_ATTR http_disconnect_callback( void * arg )
|
|||
{
|
||||
req->callback_handle( body, http_status, req->buffer );
|
||||
}
|
||||
if (req->buffer) {
|
||||
os_free( req->buffer );
|
||||
}
|
||||
os_free( req->hostname );
|
||||
os_free( req->method );
|
||||
os_free( req->path );
|
||||
os_free( req );
|
||||
http_free_req( req );
|
||||
}
|
||||
/* Fix memory leak. */
|
||||
espconn_delete( conn );
|
||||
|
@ -354,7 +364,7 @@ static void ICACHE_FLASH_ATTR http_dns_callback( const char * hostname, ip_addr_
|
|||
{
|
||||
req->callback_handle( "", -1, "" );
|
||||
}
|
||||
os_free( req );
|
||||
http_free_req( req );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue