Skip to content

Commit

Permalink
Merge pull request #426 from afx00/ptp-memory
Browse files Browse the repository at this point in the history
Memory leak
  • Loading branch information
pinealservo authored Jun 22, 2016
2 parents ef6580f + dc06c0a commit 002cfdf
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 17 deletions.
31 changes: 18 additions & 13 deletions daemons/gptp/common/ptp_message.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,6 @@ PTPMessageCommon *buildPTPMessage
messageType = (MessageType) (tspec_msg_t & 0xF);
transportSpecific = (tspec_msg_t >> 4) & 0x0F;

if (1 != transportSpecific) {
GPTP_LOG_EXCEPTION("*** Received message with unsupported transportSpecific type=%d", transportSpecific);
goto done;
}

sourcePortIdentity = new PortIdentity
((uint8_t *)
(buf + PTP_COMMON_HDR_SOURCE_CLOCK_ID
Expand Down Expand Up @@ -145,14 +140,19 @@ PTPMessageCommon *buildPTPMessage
("*** Received an event packet but cannot retrieve timestamp, discarding. messageType=%u,error=%d\n%s",
messageType, ts_good, msg);
//_exit(-1);
return NULL;
goto abort;
}

else {
GPTP_LOG_VERBOSE("Timestamping event packet");
}

}

if (1 != transportSpecific) {
GPTP_LOG_EXCEPTION("*** Received message with unsupported transportSpecific type=%d", transportSpecific);
goto abort;
}

switch (messageType) {
case SYNC_MESSAGE:
Expand All @@ -162,7 +162,7 @@ PTPMessageCommon *buildPTPMessage

// Be sure buffer is the correction size
if (size < PTP_COMMON_HDR_LENGTH + PTP_SYNC_LENGTH) {
goto done;
goto abort;
}
{
PTPMessageSync *sync_msg = new PTPMessageSync();
Expand All @@ -186,7 +186,7 @@ PTPMessageCommon *buildPTPMessage

// Be sure buffer is the correction size
if (size < (int)(PTP_COMMON_HDR_LENGTH + PTP_FOLLOWUP_LENGTH + sizeof(FollowUpTLV))) {
goto done;
goto abort;
}
{
PTPMessageFollowUp *followup_msg =
Expand Down Expand Up @@ -237,7 +237,7 @@ PTPMessageCommon *buildPTPMessage
// Be sure buffer is the correction size
if (size < PTP_COMMON_HDR_LENGTH + PTP_PDELAY_REQ_LENGTH
&& /* For Broadcom compatibility */ size != 46) {
goto done;
goto abort;
}
{
PTPMessagePathDelayReq *pdelay_req_msg =
Expand Down Expand Up @@ -285,7 +285,7 @@ PTPMessageCommon *buildPTPMessage

// Be sure buffer is the correction size
if (size < PTP_COMMON_HDR_LENGTH + PTP_PDELAY_RESP_LENGTH) {
goto done;
goto abort;
}
{
PTPMessagePathDelayResp *pdelay_resp_msg =
Expand Down Expand Up @@ -344,7 +344,7 @@ PTPMessageCommon *buildPTPMessage

// Be sure buffer is the correction size
// if( size < PTP_COMMON_HDR_LENGTH + PTP_PDELAY_FOLLOWUP_LENGTH ) {
// goto done;
// goto abort;
// }
{
PTPMessagePathDelayRespFollowUp *pdelay_resp_fwup_msg =
Expand Down Expand Up @@ -487,7 +487,7 @@ PTPMessageCommon *buildPTPMessage
(int)messageType);
port->incCounter_ieee8021AsPortStatRxPTPPacketDiscard();

goto done;
goto abort;
}

msg->_gc = false;
Expand Down Expand Up @@ -523,10 +523,15 @@ PTPMessageCommon *buildPTPMessage
msg->_timestamp = timestamp;
msg->_timestamp_counter_value = counter_value;

done:
delete timer;

return msg;

abort:
delete sourcePortIdentity;
delete timer;

return NULL;
}

void PTPMessageCommon::processMessage(IEEE1588Port * port)
Expand Down
4 changes: 0 additions & 4 deletions daemons/gptp/linux/src/daemon_cl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -320,10 +320,6 @@ int main(int argc, char **argv)
restoredataptr = (char *)restoredata;
}

if (argc < 2)
return -1;
ifname = new InterfaceName(argv[1], strlen(argv[1]));

#ifdef ARCH_INTELCE
HWTimestamper *timestamper = new LinuxTimestamperIntelCE();
#else
Expand Down

0 comments on commit 002cfdf

Please sign in to comment.