This library is used to make HTTP and HTTPS calls from mbed OS 5 applications.
Fork of mbed-http by
Revision 18:f7a85895a941, committed 2017-09-04
- Comitter:
- Jan Jongboom
- Date:
- Mon Sep 04 16:31:38 2017 +0100
- Parent:
- 17:6e0025e01b98
- Child:
- 19:a5371b71de6f
- Commit message:
- tls_socket was leaking 1024 bytes of memory
Changed in this revision
| source/http_response.h | Show annotated file Show diff for this revision Revisions of this file |
| source/tls_socket.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/source/http_response.h Mon Jul 31 15:36:33 2017 +0200
+++ b/source/http_response.h Mon Sep 04 16:31:38 2017 +0100
@@ -142,7 +142,13 @@
body = (char*)malloc(length);
}
else {
+ char* original_body = body;
body = (char*)realloc(body, body_offset + length);
+ if (body == NULL) {
+ printf("[HttpResponse] realloc for %d bytes failed\n", body_offset + length);
+ free(original_body);
+ return;
+ }
}
}
--- a/source/tls_socket.h Mon Jul 31 15:36:33 2017 +0200
+++ b/source/tls_socket.h Mon Sep 04 16:31:38 2017 +0100
@@ -161,7 +161,7 @@
if (_debug) mbedtls_printf("TLS connection to %s:%d established\r\n", _hostname, _port);
const uint32_t buf_size = 1024;
- char *buf = new char[buf_size];
+ char buf[buf_size] = { 0 };
mbedtls_x509_crt_info(buf, buf_size, "\r ",
mbedtls_ssl_get_peer_cert(&_ssl));
if (_debug) mbedtls_printf("Server certificate:\r\n%s\r", buf);
