(CC) IMPORTANT note on use of FindOrAddWaypoint() and code simply reformatted with notes.
Safe NULL pointers after memcpy in FindOrAddWaypoints, and returns -1 not false in case of error.
Fix do not save to task Comments and Details from CTaskFileHelper, and check for FindOrAddWaypoint can return -1.
Do not load to task an invalid waypoint index.
Apply fix to CTaskFileHelper LPTSR and free(szContent)
Forgotten free in previous fix
Fix LoadCupTask not managing invalid return value from FindOrAddWaypoint
Apply fix to LoadCupTask memset missing and clear mapWaypoint.
Notice that Comment and Details should always be NULL!!
If they are not null, then we most likely have an invalid pointer.