You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

61 lines
1.6 KiB

​
​
​
​
​
​
​
​
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
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. #ifndef _SQLITE_base_class_h_
  2. #define _SQLITE_base_class_h_
  3. #include "../../components/base/basicLogCollection.h"
  4. #include "../../components/base/basicMutex.h"
  5. #include "../../components/base/basicTypes.h"
  6. // #include <mysql/mysql.h>
  7. #include <sqlite3.h>
  8. #ifndef SQLITE_BUSY_TIMEOUT_MS
  9. // How long a statement waits for a lock held by another connection before failing with SQLITE_BUSY
  10. #define SQLITE_BUSY_TIMEOUT_MS 2000
  11. #endif
  12. #ifdef DEBUG_EXTRA
  13. #define DEBUG_SQLITE_QUERIES
  14. #endif
  15. class SQLite_Connector
  16. {
  17. private:
  18. basicLogCollection * m_pLog;
  19. bool m_bIsConnected;
  20. basicMutex m_mAccessMutex;
  21. sqlite3 * m_pDBLink;
  22. sqlite3_stmt * m_pResult;
  23. // MYSQL_ROW m_pRow;
  24. char m_pDBName[MAX_PATH];
  25. int m_nFLAGS;
  26. bool m_bPersistentConnection;
  27. public:
  28. SQLite_Connector();
  29. SQLite_Connector(CSTR DBHost, CSTR DBUser, CSTR DBPassword, U16 Port = 3306);
  30. SQLite_Connector(CSTR DBName, CSTR DBHost, CSTR DBUser, CSTR DBPassword, U16 Port = 3306);
  31. // MySQL_Connector( char *LocalUnixSocket, char *DBUser, char* DBPassword );
  32. virtual ~SQLite_Connector();
  33. bool Connect(CSTR FileName, int AUX_FLAGS = SQLITE_OPEN_FULLMUTEX, bool Persistent = false);
  34. CSTR escapeString(CSTR str);
  35. CSTR escapeBinary(uint8_t * Data, uint32_t Size);
  36. bool isConnected(void)
  37. {
  38. return m_bIsConnected;
  39. }
  40. uint64_t QueryID(CSTR QS);
  41. bool SilentQuery(CSTR QS);
  42. AAssoc * Query(CSTR QS, bool useCache = false);
  43. void deleteResult(AAssoc *& R);
  44. bool ReConnect(void);
  45. bool Disconnect(void);
  46. };
  47. void deleteResult(AAssoc *& ptr);
  48. // extern MySQL_Connector DBC;
  49. #endif