Chip.cpp could fail by using a NULL pointer
Reported by external programmer.
The Chip class has the potential to us a NULL pointer at line 473. The line should be checked to make sure the projection is not NULL.
473 proj->SetUniversalGround(lat, lon);
#16 Updated by Ian Humphrey almost 3 years ago
- Status changed from In Progress to Rejected
- Impact updated (diff)
Rejected because use of the Chip class's API cannot allow the proj pointer to be NULL at line 473 (see explanation below).
Note that this line of code occurs in one of Chip's Load functions (at line 320). At the beginning of this function, we initialize our Camera and Projection pointers, cam and proj, to NULL. We then check if the cube we are loading into the chip has a valid camera. If not, then we check if there is a valid map projection. If this fails, then an exception is thrown.
This yields three possibilities for the states of these pointers:
* The cam pointer is set and the proj pointer is NULL when the camera check is successful
* The cam pointer is NULL and the proj pointer is set when the camera check fails and the projection check is successful
* An exception is thrown when both the camera and projection checks fail
Now, later in this same function when we are using a lat/long to find a line/sample in the chip (starting at line 459), we check if the cam pointer is set. If it is set, we use the camera to find these values. Otherwise, we know that the proj pointer must be set (otherwise an exception would have been thrown as explained above) and subsequently use it to find the line/sample values.