Merge pull request #10354 from hasnainvirk/compile_error_at_handler

Cellular: Using new rather than malloc in debug_print
pull/10019/head
Cruz Monrreal 2019-04-09 11:06:15 -05:00 committed by GitHub
commit cec5a85761
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 2 deletions

View File

@ -1320,7 +1320,7 @@ void ATHandler::debug_print(const char *p, int len, ATType type)
#if MBED_CONF_CELLULAR_DEBUG_AT
if (_debug_on) {
const int buf_size = len * 4 + 1; // x4 -> reserve space for extra characters, +1 -> terminating null
char *buffer = (char *)malloc(buf_size);
char *buffer = new char [buf_size];
if (buffer) {
memset(buffer, 0, buf_size);
@ -1350,7 +1350,7 @@ void ATHandler::debug_print(const char *p, int len, ATType type)
tr_info("AT ERR (%2d): %s", len, buffer);
}
free(buffer);
delete [] buffer;
} else {
tr_error("AT trace unable to allocate buffer!");
}