 la_mojo: fix memory leaks and heap corruption
Continuous leaks:
- protocolParser: on package-pool overflow the oldest package was removed
but never freed while the newest (still pooled) one was freed. Every
packet a handler does not consume (e.g. other sensors on a shared bus)
leaked once the pool was full. Free the removed package, free pooled
packages in the destructor and getPackage(), use memmove for the
overlapping buffer shifts.
- SQLite_Connector::Query: loop only while sqlite3_step() returns
SQLITE_ROW. Looping until SQLITE_DONE spun forever allocating rows on
SQLITE_BUSY/ERROR. Set a busy timeout, close handles after a failed
open, fix escapeBinary() writing into uninitialised buffers.
- basicThread/basicDualThread: threads that ended by themselves were never
joined, leaking their stacks on every stream drop/restart. Always join
once (detach when called from the thread itself); check pthread_create
result correctly.
- curlRequest: free the header list; initialise m_pPostData and the
content type; curlRequestsManager deletes requests it cannot queue.
- kernelModuleModemManager: free the phonebook ID list on every reload.
- deviceNodeFactory: do not append the same pending node every cycle.
- streamHandler: free frames left in the encoding queue on destruction.
Heap corruption:
- kernelModuleFactory: module that failed to start was deleted twice.
- mojoRemoteClient: basicRing::push() returns an ID (may be 0), not a
bool; compare with -1. Fix packetExtractor and destructor leaks.
- utilizeBasicEvent: payloads are malloc'ed, release with free().
- videoAVLIBSource: avoid sws context double free, NULL check order.
- trim(): memmove for overlapping copy.
Smaller leaks: dropSession duplicate query, LRF upload data, report
backupper / fly hunter settings, Kafka consumer handle, BVMS uniq ID.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN16
24 hours ago  la_mojo: fix memory leaks and heap corruption
Continuous leaks:
- protocolParser: on package-pool overflow the oldest package was removed
but never freed while the newest (still pooled) one was freed. Every
packet a handler does not consume (e.g. other sensors on a shared bus)
leaked once the pool was full. Free the removed package, free pooled
packages in the destructor and getPackage(), use memmove for the
overlapping buffer shifts.
- SQLite_Connector::Query: loop only while sqlite3_step() returns
SQLITE_ROW. Looping until SQLITE_DONE spun forever allocating rows on
SQLITE_BUSY/ERROR. Set a busy timeout, close handles after a failed
open, fix escapeBinary() writing into uninitialised buffers.
- basicThread/basicDualThread: threads that ended by themselves were never
joined, leaking their stacks on every stream drop/restart. Always join
once (detach when called from the thread itself); check pthread_create
result correctly.
- curlRequest: free the header list; initialise m_pPostData and the
content type; curlRequestsManager deletes requests it cannot queue.
- kernelModuleModemManager: free the phonebook ID list on every reload.
- deviceNodeFactory: do not append the same pending node every cycle.
- streamHandler: free frames left in the encoding queue on destruction.
Heap corruption:
- kernelModuleFactory: module that failed to start was deleted twice.
- mojoRemoteClient: basicRing::push() returns an ID (may be 0), not a
bool; compare with -1. Fix packetExtractor and destructor leaks.
- utilizeBasicEvent: payloads are malloc'ed, release with free().
- videoAVLIBSource: avoid sws context double free, NULL check order.
- trim(): memmove for overlapping copy.
Smaller leaks: dropSession duplicate query, LRF upload data, report
backupper / fly hunter settings, Kafka consumer handle, BVMS uniq ID.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN16
24 hours ago  la_mojo: fix memory leaks and heap corruption
Continuous leaks:
- protocolParser: on package-pool overflow the oldest package was removed
but never freed while the newest (still pooled) one was freed. Every
packet a handler does not consume (e.g. other sensors on a shared bus)
leaked once the pool was full. Free the removed package, free pooled
packages in the destructor and getPackage(), use memmove for the
overlapping buffer shifts.
- SQLite_Connector::Query: loop only while sqlite3_step() returns
SQLITE_ROW. Looping until SQLITE_DONE spun forever allocating rows on
SQLITE_BUSY/ERROR. Set a busy timeout, close handles after a failed
open, fix escapeBinary() writing into uninitialised buffers.
- basicThread/basicDualThread: threads that ended by themselves were never
joined, leaking their stacks on every stream drop/restart. Always join
once (detach when called from the thread itself); check pthread_create
result correctly.
- curlRequest: free the header list; initialise m_pPostData and the
content type; curlRequestsManager deletes requests it cannot queue.
- kernelModuleModemManager: free the phonebook ID list on every reload.
- deviceNodeFactory: do not append the same pending node every cycle.
- streamHandler: free frames left in the encoding queue on destruction.
Heap corruption:
- kernelModuleFactory: module that failed to start was deleted twice.
- mojoRemoteClient: basicRing::push() returns an ID (may be 0), not a
bool; compare with -1. Fix packetExtractor and destructor leaks.
- utilizeBasicEvent: payloads are malloc'ed, release with free().
- videoAVLIBSource: avoid sws context double free, NULL check order.
- trim(): memmove for overlapping copy.
Smaller leaks: dropSession duplicate query, LRF upload data, report
backupper / fly hunter settings, Kafka consumer handle, BVMS uniq ID.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN16
24 hours ago  la_mojo: fix memory leaks and heap corruption
Continuous leaks:
- protocolParser: on package-pool overflow the oldest package was removed
but never freed while the newest (still pooled) one was freed. Every
packet a handler does not consume (e.g. other sensors on a shared bus)
leaked once the pool was full. Free the removed package, free pooled
packages in the destructor and getPackage(), use memmove for the
overlapping buffer shifts.
- SQLite_Connector::Query: loop only while sqlite3_step() returns
SQLITE_ROW. Looping until SQLITE_DONE spun forever allocating rows on
SQLITE_BUSY/ERROR. Set a busy timeout, close handles after a failed
open, fix escapeBinary() writing into uninitialised buffers.
- basicThread/basicDualThread: threads that ended by themselves were never
joined, leaking their stacks on every stream drop/restart. Always join
once (detach when called from the thread itself); check pthread_create
result correctly.
- curlRequest: free the header list; initialise m_pPostData and the
content type; curlRequestsManager deletes requests it cannot queue.
- kernelModuleModemManager: free the phonebook ID list on every reload.
- deviceNodeFactory: do not append the same pending node every cycle.
- streamHandler: free frames left in the encoding queue on destruction.
Heap corruption:
- kernelModuleFactory: module that failed to start was deleted twice.
- mojoRemoteClient: basicRing::push() returns an ID (may be 0), not a
bool; compare with -1. Fix packetExtractor and destructor leaks.
- utilizeBasicEvent: payloads are malloc'ed, release with free().
- videoAVLIBSource: avoid sws context double free, NULL check order.
- trim(): memmove for overlapping copy.
Smaller leaks: dropSession duplicate query, LRF upload data, report
backupper / fly hunter settings, Kafka consumer handle, BVMS uniq ID.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN16
24 hours ago  la_mojo: fix memory leaks and heap corruption
Continuous leaks:
- protocolParser: on package-pool overflow the oldest package was removed
but never freed while the newest (still pooled) one was freed. Every
packet a handler does not consume (e.g. other sensors on a shared bus)
leaked once the pool was full. Free the removed package, free pooled
packages in the destructor and getPackage(), use memmove for the
overlapping buffer shifts.
- SQLite_Connector::Query: loop only while sqlite3_step() returns
SQLITE_ROW. Looping until SQLITE_DONE spun forever allocating rows on
SQLITE_BUSY/ERROR. Set a busy timeout, close handles after a failed
open, fix escapeBinary() writing into uninitialised buffers.
- basicThread/basicDualThread: threads that ended by themselves were never
joined, leaking their stacks on every stream drop/restart. Always join
once (detach when called from the thread itself); check pthread_create
result correctly.
- curlRequest: free the header list; initialise m_pPostData and the
content type; curlRequestsManager deletes requests it cannot queue.
- kernelModuleModemManager: free the phonebook ID list on every reload.
- deviceNodeFactory: do not append the same pending node every cycle.
- streamHandler: free frames left in the encoding queue on destruction.
Heap corruption:
- kernelModuleFactory: module that failed to start was deleted twice.
- mojoRemoteClient: basicRing::push() returns an ID (may be 0), not a
bool; compare with -1. Fix packetExtractor and destructor leaks.
- utilizeBasicEvent: payloads are malloc'ed, release with free().
- videoAVLIBSource: avoid sws context double free, NULL check order.
- trim(): memmove for overlapping copy.
Smaller leaks: dropSession duplicate query, LRF upload data, report
backupper / fly hunter settings, Kafka consumer handle, BVMS uniq ID.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN16
24 hours ago  la_mojo: fix memory leaks and heap corruption
Continuous leaks:
- protocolParser: on package-pool overflow the oldest package was removed
but never freed while the newest (still pooled) one was freed. Every
packet a handler does not consume (e.g. other sensors on a shared bus)
leaked once the pool was full. Free the removed package, free pooled
packages in the destructor and getPackage(), use memmove for the
overlapping buffer shifts.
- SQLite_Connector::Query: loop only while sqlite3_step() returns
SQLITE_ROW. Looping until SQLITE_DONE spun forever allocating rows on
SQLITE_BUSY/ERROR. Set a busy timeout, close handles after a failed
open, fix escapeBinary() writing into uninitialised buffers.
- basicThread/basicDualThread: threads that ended by themselves were never
joined, leaking their stacks on every stream drop/restart. Always join
once (detach when called from the thread itself); check pthread_create
result correctly.
- curlRequest: free the header list; initialise m_pPostData and the
content type; curlRequestsManager deletes requests it cannot queue.
- kernelModuleModemManager: free the phonebook ID list on every reload.
- deviceNodeFactory: do not append the same pending node every cycle.
- streamHandler: free frames left in the encoding queue on destruction.
Heap corruption:
- kernelModuleFactory: module that failed to start was deleted twice.
- mojoRemoteClient: basicRing::push() returns an ID (may be 0), not a
bool; compare with -1. Fix packetExtractor and destructor leaks.
- utilizeBasicEvent: payloads are malloc'ed, release with free().
- videoAVLIBSource: avoid sws context double free, NULL check order.
- trim(): memmove for overlapping copy.
Smaller leaks: dropSession duplicate query, LRF upload data, report
backupper / fly hunter settings, Kafka consumer handle, BVMS uniq ID.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN16
24 hours ago  la_mojo: fix memory leaks and heap corruption
Continuous leaks:
- protocolParser: on package-pool overflow the oldest package was removed
but never freed while the newest (still pooled) one was freed. Every
packet a handler does not consume (e.g. other sensors on a shared bus)
leaked once the pool was full. Free the removed package, free pooled
packages in the destructor and getPackage(), use memmove for the
overlapping buffer shifts.
- SQLite_Connector::Query: loop only while sqlite3_step() returns
SQLITE_ROW. Looping until SQLITE_DONE spun forever allocating rows on
SQLITE_BUSY/ERROR. Set a busy timeout, close handles after a failed
open, fix escapeBinary() writing into uninitialised buffers.
- basicThread/basicDualThread: threads that ended by themselves were never
joined, leaking their stacks on every stream drop/restart. Always join
once (detach when called from the thread itself); check pthread_create
result correctly.
- curlRequest: free the header list; initialise m_pPostData and the
content type; curlRequestsManager deletes requests it cannot queue.
- kernelModuleModemManager: free the phonebook ID list on every reload.
- deviceNodeFactory: do not append the same pending node every cycle.
- streamHandler: free frames left in the encoding queue on destruction.
Heap corruption:
- kernelModuleFactory: module that failed to start was deleted twice.
- mojoRemoteClient: basicRing::push() returns an ID (may be 0), not a
bool; compare with -1. Fix packetExtractor and destructor leaks.
- utilizeBasicEvent: payloads are malloc'ed, release with free().
- videoAVLIBSource: avoid sws context double free, NULL check order.
- trim(): memmove for overlapping copy.
Smaller leaks: dropSession duplicate query, LRF upload data, report
backupper / fly hunter settings, Kafka consumer handle, BVMS uniq ID.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN16
24 hours ago  la_mojo: fix memory leaks and heap corruption
Continuous leaks:
- protocolParser: on package-pool overflow the oldest package was removed
but never freed while the newest (still pooled) one was freed. Every
packet a handler does not consume (e.g. other sensors on a shared bus)
leaked once the pool was full. Free the removed package, free pooled
packages in the destructor and getPackage(), use memmove for the
overlapping buffer shifts.
- SQLite_Connector::Query: loop only while sqlite3_step() returns
SQLITE_ROW. Looping until SQLITE_DONE spun forever allocating rows on
SQLITE_BUSY/ERROR. Set a busy timeout, close handles after a failed
open, fix escapeBinary() writing into uninitialised buffers.
- basicThread/basicDualThread: threads that ended by themselves were never
joined, leaking their stacks on every stream drop/restart. Always join
once (detach when called from the thread itself); check pthread_create
result correctly.
- curlRequest: free the header list; initialise m_pPostData and the
content type; curlRequestsManager deletes requests it cannot queue.
- kernelModuleModemManager: free the phonebook ID list on every reload.
- deviceNodeFactory: do not append the same pending node every cycle.
- streamHandler: free frames left in the encoding queue on destruction.
Heap corruption:
- kernelModuleFactory: module that failed to start was deleted twice.
- mojoRemoteClient: basicRing::push() returns an ID (may be 0), not a
bool; compare with -1. Fix packetExtractor and destructor leaks.
- utilizeBasicEvent: payloads are malloc'ed, release with free().
- videoAVLIBSource: avoid sws context double free, NULL check order.
- trim(): memmove for overlapping copy.
Smaller leaks: dropSession duplicate query, LRF upload data, report
backupper / fly hunter settings, Kafka consumer handle, BVMS uniq ID.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN16
24 hours ago  la_mojo: fix memory leaks and heap corruption
Continuous leaks:
- protocolParser: on package-pool overflow the oldest package was removed
but never freed while the newest (still pooled) one was freed. Every
packet a handler does not consume (e.g. other sensors on a shared bus)
leaked once the pool was full. Free the removed package, free pooled
packages in the destructor and getPackage(), use memmove for the
overlapping buffer shifts.
- SQLite_Connector::Query: loop only while sqlite3_step() returns
SQLITE_ROW. Looping until SQLITE_DONE spun forever allocating rows on
SQLITE_BUSY/ERROR. Set a busy timeout, close handles after a failed
open, fix escapeBinary() writing into uninitialised buffers.
- basicThread/basicDualThread: threads that ended by themselves were never
joined, leaking their stacks on every stream drop/restart. Always join
once (detach when called from the thread itself); check pthread_create
result correctly.
- curlRequest: free the header list; initialise m_pPostData and the
content type; curlRequestsManager deletes requests it cannot queue.
- kernelModuleModemManager: free the phonebook ID list on every reload.
- deviceNodeFactory: do not append the same pending node every cycle.
- streamHandler: free frames left in the encoding queue on destruction.
Heap corruption:
- kernelModuleFactory: module that failed to start was deleted twice.
- mojoRemoteClient: basicRing::push() returns an ID (may be 0), not a
bool; compare with -1. Fix packetExtractor and destructor leaks.
- utilizeBasicEvent: payloads are malloc'ed, release with free().
- videoAVLIBSource: avoid sws context double free, NULL check order.
- trim(): memmove for overlapping copy.
Smaller leaks: dropSession duplicate query, LRF upload data, report
backupper / fly hunter settings, Kafka consumer handle, BVMS uniq ID.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN16
24 hours ago  la_mojo: fix memory leaks and heap corruption
Continuous leaks:
- protocolParser: on package-pool overflow the oldest package was removed
but never freed while the newest (still pooled) one was freed. Every
packet a handler does not consume (e.g. other sensors on a shared bus)
leaked once the pool was full. Free the removed package, free pooled
packages in the destructor and getPackage(), use memmove for the
overlapping buffer shifts.
- SQLite_Connector::Query: loop only while sqlite3_step() returns
SQLITE_ROW. Looping until SQLITE_DONE spun forever allocating rows on
SQLITE_BUSY/ERROR. Set a busy timeout, close handles after a failed
open, fix escapeBinary() writing into uninitialised buffers.
- basicThread/basicDualThread: threads that ended by themselves were never
joined, leaking their stacks on every stream drop/restart. Always join
once (detach when called from the thread itself); check pthread_create
result correctly.
- curlRequest: free the header list; initialise m_pPostData and the
content type; curlRequestsManager deletes requests it cannot queue.
- kernelModuleModemManager: free the phonebook ID list on every reload.
- deviceNodeFactory: do not append the same pending node every cycle.
- streamHandler: free frames left in the encoding queue on destruction.
Heap corruption:
- kernelModuleFactory: module that failed to start was deleted twice.
- mojoRemoteClient: basicRing::push() returns an ID (may be 0), not a
bool; compare with -1. Fix packetExtractor and destructor leaks.
- utilizeBasicEvent: payloads are malloc'ed, release with free().
- videoAVLIBSource: avoid sws context double free, NULL check order.
- trim(): memmove for overlapping copy.
Smaller leaks: dropSession duplicate query, LRF upload data, report
backupper / fly hunter settings, Kafka consumer handle, BVMS uniq ID.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN16
24 hours ago |
|
//----------------------------------------------------------------------------
// Dr.Frucht Systems Ltd.
// Copyright © 2000-2016. All Rights Reserved.
// Version 2.0 3/30/2016
// Last modification: 3/30/2016
// PROJECT:
// SUBSYSTEM:
// FILE: basicEvent.cpp
// AUTHOR: gagua
// OVERVIEW
// ~~~~~~~~
// Header file of basicEvent.cpp
//----------------------------------------------------------------------------
//
#include "basicEvent.h"
#include "basicFunctionality.h"
void utilizeBasicEvent(EVENT_CONTAINER & Evt){ if (Evt.m_pHumanReadableMsg != NULL) { free( Evt.m_pHumanReadableMsg ); // The mem is allocated by malloc!!
Evt.m_pHumanReadableMsg = NULL; }; if (Evt.m_pEvtData != NULL) { switch (Evt.m_eType) { case EVT_FH_MISSION_BEGIN: case EVT_FH_BUSY: case EVT_FH_CANCEL_ACTION : free(Evt.m_pEvtData); break; // allocated with malloc everywhere
case EVT_FH_FLY_TO : case EVT_FH_WAYPOINT : case EVT_FH_DEST_REACHED : case EVT_FH_JAMER_ON : case EVT_FH_JAMER_OFF : case EVT_FH_TARGET_LOCKED : case EVT_FH_INTERCEPT_BEGIN: case EVT_FH_INTERCEPT_OK : case EVT_FH_INTERCEPT_NOK : case EVT_FH_MISSION_END : free(Evt.m_pEvtData); break; // allocated with malloc everywhere
case EVT_TARGET_1D: case EVT_TARGET_2D_WHITE: case EVT_TARGET_2D_BLACK: case EVT_TARGET_3D_WHITE: case EVT_TARGET_3D_BLACK: case EVT_CAMERA_MOVE_TO: { free(Evt.m_pEvtData); // allocated with malloc everywhere (delete was an allocator mismatch)
break; }; default: free(Evt.m_pEvtData); }; }; Evt.m_pEvtData = NULL; Evt.m_eType = EVT_NOINIT;}
void utilizeBasicEvent(EVENT_CONTAINER *& Evt){ if (Evt == NULL) { return; } if (Evt->m_pHumanReadableMsg != NULL) { free( Evt->m_pHumanReadableMsg ); // The mem is allocated by malloc!!
Evt->m_pHumanReadableMsg = NULL; }; if (Evt->m_pEvtData != NULL) { switch (Evt->m_eType) { case EVT_FH_MISSION_BEGIN: case EVT_FH_BUSY: case EVT_FH_CANCEL_ACTION : free(Evt->m_pEvtData); break; // allocated with malloc everywhere
case EVT_FH_FLY_TO : case EVT_FH_WAYPOINT : case EVT_FH_DEST_REACHED : case EVT_FH_JAMER_ON : case EVT_FH_JAMER_OFF : case EVT_FH_TARGET_LOCKED : case EVT_FH_INTERCEPT_BEGIN: case EVT_FH_INTERCEPT_OK : case EVT_FH_INTERCEPT_NOK : case EVT_FH_MISSION_END : free(Evt->m_pEvtData); break; // allocated with malloc everywhere
case EVT_TARGET_1D: case EVT_TARGET_2D_WHITE: case EVT_TARGET_2D_BLACK: case EVT_TARGET_3D_WHITE: case EVT_TARGET_3D_BLACK: case EVT_CAMERA_MOVE_TO: { free(Evt->m_pEvtData); // allocated with malloc everywhere (delete was an allocator mismatch)
break; }; default: free(Evt->m_pEvtData); }; }; free(Evt); Evt = NULL;}
static uint32_t EventSeed_Counter = 0;
EVENT_CONTAINER * createBasicEvent(uint64_t SRC, basicEventClassID Class, basicEventTypeID Type, char * RefUUID, char * Msg, void * Data, uint32_t tss, uint16_t tms){ EVENT_CONTAINER * tEvent; tEvent = (EVENT_CONTAINER *) malloc(sizeof(EVENT_CONTAINER)); if (tEvent) { if (tss == 0) { time_t t = time(NULL); localtime_r( &t, &tEvent->sTS );// MT safe
tEvent->m_UMSTS = getMilliseconds(); } else { time_t t = (time_t) tss; localtime_r( &t, &tEvent->sTS );// MT safe
tEvent->m_UMSTS = tss; tEvent->m_UMSTS = tEvent->m_UMSTS * 1000 + tms; }; tEvent->m_eClass = Class; CSTR tUUID = getUniqID_UUID(EventSeed_Counter++); if (tUUID) { sprintf(tEvent->m_UUID, "%s", tUUID); free(tUUID); } else { memset(tEvent->m_UUID, 0, 65); }; tEvent->m_ref_UUID[0] = (char) 0; // malloc'ed struct: was left uninitialised without RefUUID
tEvent->m_db_id = 0; tEvent->m_ref_id = 0; if (RefUUID) { snprintf(tEvent->m_ref_UUID, sizeof(tEvent->m_ref_UUID), "%s", RefUUID); }; tEvent->m_eType = Type; tEvent->m_nDestinationNodeID = 0; // Broadcast
tEvent->m_nSourceNodeID = SRC; tEvent->m_pEvtData = Data; if (Msg != NULL) { tEvent->m_pHumanReadableMsg = (char *) malloc(strlen(Msg) + 1); if (tEvent->m_pHumanReadableMsg) { strcpy(tEvent->m_pHumanReadableMsg, Msg); }; } else { tEvent->m_pHumanReadableMsg = NULL; }; }; return tEvent;}
EVENT_CONTAINER * createBasicTargetedEvent(uint64_t SRC, uint64_t DST, basicEventClassID Class, basicEventTypeID Type, char * RefUUID, char * Msg, void * Data, uint32_t tss, uint16_t tms){ EVENT_CONTAINER * tEvent; tEvent = (EVENT_CONTAINER *) malloc(sizeof(EVENT_CONTAINER)); if (tEvent) { if (tss == 0) { time_t t = time(NULL); localtime_r( &t, &tEvent->sTS );// MT safe
tEvent->m_UMSTS = getMilliseconds(); } else { time_t t = (time_t) tss; localtime_r( &t, &tEvent->sTS );// MT safe
tEvent->m_UMSTS = tss; tEvent->m_UMSTS = tEvent->m_UMSTS * 1000 + tms; }; tEvent->m_eClass = Class; CSTR tUUID = getUniqID_UUID(); if (tUUID) { sprintf(tEvent->m_UUID, "%s", tUUID); free(tUUID); } else { memset(tEvent->m_UUID, 0, 65); }; tEvent->m_ref_UUID[0] = (char) 0; // malloc'ed struct: was left uninitialised without RefUUID
tEvent->m_db_id = 0; tEvent->m_ref_id = 0; if (RefUUID) { snprintf(tEvent->m_ref_UUID, sizeof(tEvent->m_ref_UUID), "%s", RefUUID); }; tEvent->m_eType = Type; tEvent->m_nDestinationNodeID = DST; tEvent->m_nSourceNodeID = SRC; tEvent->m_pEvtData = Data; if (Msg != NULL) { tEvent->m_pHumanReadableMsg = (char *) malloc(strlen(Msg) + 1); if (tEvent->m_pHumanReadableMsg) { strcpy(tEvent->m_pHumanReadableMsg, Msg); }; } else { tEvent->m_pHumanReadableMsg = NULL; }; }; return tEvent;}
|