Opened 5 years ago
Last modified 5 years ago
#5599 new defect
Fix some Major CppCheck warnings
Reported by: | Stan | Owned by: | |
---|---|---|---|
Priority: | Should Have | Milestone: | Backlog |
Component: | Core engine | Keywords: | |
Cc: | Krinkle | Patch: |
Description
- Memory pointed to by 'start' is freed twice.
- https://cwe.mitre.org/data/definitions/415.html
- source/lib/sysdep/os/win/wposix/wmman.cpp@229
int munmap(void* start, size_t UNUSED(len)) { // UnmapViewOfFile checks if start was returned by MapViewOfFile*; // if not, it will fail. BOOL ok = UnmapViewOfFile(start); if(!ok) // VirtualFree requires dwSize to be 0 (entire region is released). → ok = VirtualFree(start, 0, MEM_RELEASE); WARN_IF_FALSE(ok); return ok? 0 : -1; }
- Resource leak: hSemaphore
- https://cwe.mitre.org/data/definitions/775.html
- source/lib/sysdep/os/win/wposix/wpthread.cpp@426
// we have to return a pointer to sem_t, and the sem_init interface // requires sem_t to be usable as the handle, so we'll have to // allocate memory here (ugh). sem_t* sem = new sem_t; *sem = (sem_t)hSemaphore; → return sem;
- Invalid calloc() argument nr 1. The value is 0 but the valid values are '1:'
- https://cwe.mitre.org/data/definitions/628.html
- source/lib/sysdep/smbios.cpp@427
// (instead of counting the total string size, just use the // SMBIOS size - typically 1-2 KB - as an upper bound.) → stringStoragePos = stringStorage = (char*)calloc(table.size(), sizeof(char)); // freed in Cleanup if(!stringStorage) WARN_RETURN(ERR::NO_MEM);
- Uninitialized struct member: frame.timeStart
- https://cwe.mitre.org/data/definitions/628.html
- source/ps/Profiler2GPU.cpp@183
- source/ps/Profiler2GPU.cpp@330
- source/ps/Profiler2GPU.cpp@531
} else { // Reuse the previous frame's sync data frame.syncTimeStart = m_Frames[m_Frames.size()-1].syncTimeStart; frame.syncTimestampStart = m_Frames[m_Frames.size()-1].syncTimestampStart; } → m_Frames.push_back(frame); ... void FrameStart() { ProcessFrames(); SFrame frame; frame.num = m_Profiler.GetFrameNumber(); frame.timeStart = m_Profiler.GetTime(); → m_Frames.push_back(frame); ... void FrameStart() { ProcessFrames(); SFrame frame; frame.num = m_Profiler.GetFrameNumber(); frame.timeStart = m_Profiler.GetTime(); → m_Frames.push_back(frame);
- Uninitialized struct member: obj.owner
- https://cwe.mitre.org/data/definitions/908.html
- source/.../atlas/GameInterface/Handlers/ObjectHandlers.cpp@1042
CmpPtr<ICmpPosition> cmpPosition(sim, obj.entityID); if (cmpPosition) { obj.pos = cmpPosition->GetPosition(); obj.rot = cmpPosition->GetRotation(); } oldObjects.push_back(obj);
Attachments (1)
Change History (2)
by , 5 years ago
Attachment: | cppcheck-result.7z added |
---|
comment:1 by , 5 years ago
Cc: | added |
---|
Note:
See TracTickets
for help on using tickets.
File obtained by running cppcheck 1.88 with the following flags --xml-version=2 --language=c++ --std=c++11 --max-ctu-depth=16 --enable=all --quiet --xml