text: /* TEMPLATE GENERATED TESTCASE FILE
  Filename: CWE476_NULL_Pointer_Dereference__struct_65a.c
  Label Definition File: CWE476_NULL_Pointer_Dereference.label.xml
  Template File: sources-sink-65a.tmpl.c
  */
  /*
   * @description
   * CWE: 476 NULL Pointer Dereference
   * BadSource:  Set data to NULL
   * GoodSource: Initialize data
   * Sinks:
   *    BadSink : Print data
   * Flow Variant: 65 Data/control flow: data passed as an argument from one function to a function in a different source file called via a function pointer
   *
   * */
  
  #include "std_testcase.h"
  
  #include <wchar.h>
  
  #ifndef OMITBAD
  
  /* bad function declaration */
  void CWE476_NULL_Pointer_Dereference__struct_65b_bad_sink(twoints * data);
  
  void CWE476_NULL_Pointer_Dereference__struct_65_bad()
  {
      twoints * data;
      /* define a function pointer */
      void (*func_ptr) (twoints *) = CWE476_NULL_Pointer_Dereference__struct_65b_bad_sink;
      /* Initialize data */
      data = NULL;
      /* FLAW: Set data to NULL - it will be used in the sink */
      data = NULL;
      /* use the function pointer */
      func_ptr(data);
  }
  
  #endif /* OMITBAD */
  
  #ifndef OMITGOOD
  
  /* goodG2B uses the GoodSource with the BadSink */
  void CWE476_NULL_Pointer_Dereference__struct_65b_goodG2B_sink(twoints * data);
  
  static void goodG2B()
  {
      twoints * data;
      void (*func_ptr) (twoints *) = CWE476_NULL_Pointer_Dereference__struct_65b_goodG2B_sink;
      /* Initialize data */
      data = NULL;
      /* FIX: Initialize data - it will be used in the sink */
      {
          twoints tmp;
          tmp.a = 0;
          tmp.b = 0;
          data = &tmp;
      }
      func_ptr(data);
  }
  
  void CWE476_NULL_Pointer_Dereference__struct_65_good()
  {
      goodG2B();
  }
  
  #endif /* OMITGOOD */
  
  /* Below is the main(). It is only used when building this testcase on
     its own for testing or for building a binary to use in testing binary
     analysis tools. It is not used when compiling all the testcases as one
     application, which is how source code analysis tools are tested. */
  
  #ifdef INCLUDEMAIN
  
  int main(int argc, char * argv[])
  {
      /* seed randomness */
      srand( (unsigned)time(NULL) );
  #ifndef OMITGOOD
      printLine("Calling good()...");
      CWE476_NULL_Pointer_Dereference__struct_65_good();
      printLine("Finished good()");
  #endif /* OMITGOOD */
  #ifndef OMITBAD
      printLine("Calling bad()...");
      CWE476_NULL_Pointer_Dereference__struct_65_bad();
      printLine("Finished bad()");
  #endif /* OMITBAD */
      return 0;
  }
  
  #endif
  