Commit b21b3e08 authored by Arnim Läuger's avatar Arnim Läuger Committed by Marcel Stör
Browse files

Free HTTP headers and post data memory in disconnect and DNS failure callback (#1403)

parent cc2fee5e
......@@ -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
{
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment