httpd: post example: free pbuf in httpd_post_receive_data

See bug #57742

Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
This commit is contained in:
Simon Goldschmidt 2020-02-04 22:12:14 +01:00
parent 064d816ea1
commit 3034e9fad0

View File

@ -91,6 +91,10 @@ httpd_post_begin(void *connection, const char *uri, const char *http_request,
err_t
httpd_post_receive_data(void *connection, struct pbuf *p)
{
err_t ret;
LWIP_ASSERT("NULL pbuf", p = NULL);
if (current_connection == connection) {
u16_t token_user = pbuf_memfind(p, "user=", 5, 0);
u16_t token_pass = pbuf_memfind(p, "pass=", 5, 0);
@ -134,9 +138,15 @@ httpd_post_receive_data(void *connection, struct pbuf *p)
}
/* not returning ERR_OK aborts the connection, so return ERR_OK unless the
conenction is unknown */
return ERR_OK;
ret = ERR_OK;
} else {
ret = ERR_VAL;
}
return ERR_VAL;
/* this function must ALWAYS free the pbuf it is passed or it will leak memory */
pbuf_free(p);
return ret;
}
void