Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: MQTTGateway2 MQTTGatewayK64 http-example-wnc GuardRoom ... more
Revision 39:a8d157986ad8, committed 2019-08-12
- Comitter:
- Jan Jongboom
- Date:
- Mon Aug 12 11:45:31 2019 +0200
- Parent:
- 38:bfd37a21f367
- Commit message:
- Fix parsed url leaking memory if path is empty
Changed in this revision
source/http_parsed_url.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/source/http_parsed_url.h Fri Aug 09 13:23:47 2019 +0200 +++ b/source/http_parsed_url.h Mon Aug 12 11:45:31 2019 +0200 @@ -30,7 +30,7 @@ char* value; if (parsed_url.field_set & (1 << ix)) { value = (char*)calloc(parsed_url.field_data[ix].len + 1, 1); - memcpy((void*)value, url + parsed_url.field_data[ix].off, + memcpy(value, url + parsed_url.field_data[ix].off, parsed_url.field_data[ix].len); } else { @@ -45,7 +45,7 @@ case UF_USERINFO: _userinfo = value; break; default: // PORT is already parsed, FRAGMENT is not relevant for HTTP requests - free((void*)value); + free(value); break; } } @@ -61,17 +61,18 @@ } if (strcmp(_path, "") == 0) { + free(_path); _path = (char*)calloc(2, 1); _path[0] = '/'; } } ~ParsedUrl() { - if (_schema) free((void*)_schema); - if (_host) free((void*)_host); - if (_path) free((void*)_path); - if (_query) free((void*)_query); - if (_userinfo) free((void*)_userinfo); + if (_schema) free(_schema); + if (_host) free(_host); + if (_path) free(_path); + if (_query) free(_query); + if (_userinfo) free(_userinfo); } uint16_t port() const { return _port; }