Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
bgColor#FFCCCC
void incr(int *intptr) {
  if (intptr == NULL) {
    /* Handle error */
  }
  *intptr++;
}

Compliant Solution

In this compliant solution the This incr() function can be improved by using the valid() function. The resulting implementation is less likely to dereference an invalid pointer or write to memory that is outside the bounds of a valid object.

...

Compliant Solution (assert)

In this compliant solution because Because invalid pointers are often indicative of a defect in the program, the assert() macro can be used to terminate immediately if an invalid pointer is discovered (see MSC11-C. Incorporate diagnostic tests using assertions).

...