#54 NULL IPM pointer in profil()

open
nobody
None
5
2011-03-13
2011-03-13
Trevor Scroggins
No

On systems with with a processor that does not support performancemonitor.resource, e.g. the AMCC PowerPC 440EP, profil() generates a DSI at process termination when buffer == 0. A pointer to PerformanceMonitorIFace is never obtained, and the call to IPM->EventControlTags() when buffer == 0 attempts to dereference a NULL pointer. A quick fix might check that IPM != NULL before disabling profiling:

int
profil(unsigned short *buffer, size_t bufSize, size_t offset, unsigned int scale)
{
APTR Stack;

if (buffer == 0)
{
if (!IPM)
return 0;

Stack = SuperState();
IPM->EventControlTags(
PMECT_Disable, PMEC_MasterInterrupt,
TAG_DONE);
...

Discussion