Versions Compared

Key

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

...

Code Block
bgColor#FFCCCC
int *p1, *p2;
p1 = foo();
p2 = bar();

if(baz())
   return p1;
else
    p2 = p1;
return p2;

Note this example assumes that the results of foo() and bar() are valid DCL30-C.

Compliant Solution

This example can be corrected many different ways depending on the intent of the programmer. In this compliant solution, p2 is initialized to NULL rather than the result of bar().

...