From 94183d9ac8355f1dd17f4a8cbb15f60bb6ad9052 Mon Sep 17 00:00:00 2001 From: vivek-shankar Date: Sun, 29 Jan 2017 14:12:39 -0500 Subject: [PATCH] fix for malloc error --- src/CommunicationManager.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/CommunicationManager.cpp b/src/CommunicationManager.cpp index f7693b0..ad7d44f 100644 --- a/src/CommunicationManager.cpp +++ b/src/CommunicationManager.cpp @@ -687,7 +687,7 @@ inline void CommunicationManager::Send_Mavlink_Message_Callback( uint64_t message_obt[mavlink_msg->payload64.size()]; /*buffer for easy handel operation*/ uint8_t* cpy_buff = (uint8_t*)malloc( sizeof(uint64_t)+sizeof(uint16_t) + ( sizeof(uint64_t)*MAX_NBR_OF_INT64 ) ); - memset(cpy_buff, 0,sizeof(uint64_t) + ( sizeof(uint64_t)*MAX_NBR_OF_INT64 )); + memset(cpy_buff, 0,sizeof(uint64_t)+sizeof(uint16_t) + ( sizeof(uint64_t)*MAX_NBR_OF_INT64 )); for (std::size_t i =0; ipayload64.size(); i++) { message_obt[i] =(uint64_t)mavlink_msg->payload64[i]; @@ -733,7 +733,7 @@ inline void CommunicationManager::Send_Mavlink_Message_Callback( tot =0; number++; frame = ""; - memset(cpy_buff, 0,sizeof(uint64_t)+sizeof(uint16_t) + ( sizeof(uint64_t)*mavlink_msg->payload64.size() )); + memset(cpy_buff, 0,sizeof(uint64_t)+sizeof(uint16_t) + ( sizeof(uint64_t)*MAX_NBR_OF_INT64 )); //std::cout << "total:" <payload64.size()){ tmp_size=mavlink_msg->payload64.size() - uint64_counter; /*Copy the header*/