text: /* TEMPLATE GENERATED TESTCASE FILE
  Filename: CWE762_Mismatched_Memory_Management_Routines__delete_struct_malloc_66b.cpp
  Label Definition File: CWE762_Mismatched_Memory_Management_Routines__delete.label.xml
  Template File: sources-sinks-66b.tmpl.cpp
  */
  /*
   * @description
   * CWE: 762 Mismatched Memory Management Routines
   * BadSource: malloc Allocate data using malloc()
   * GoodSource: Allocate data using new
   * Sinks:
   *    GoodSink: Deallocate data using free()
   *    BadSink : Deallocate data using delete
   * Flow Variant: 66 Data flow: data passed in an array from one function to another in different source files
   *
   * */
  
  #include "std_testcase.h"
  
  namespace CWE762_Mismatched_Memory_Management_Routines__delete_struct_malloc_66
  {
  
  #ifndef OMITBAD
  
  void bad_sink(twoints * data_array[])
  {
      /* copy data out of data_array */
      twoints * data = data_array[2];
      /* POTENTIAL FLAW: Deallocate memory using delete - the source memory allocation function may
       * require a call to free() to deallocate the memory */
      delete data;
  }
  
  #endif /* OMITBAD */
  
  #ifndef OMITGOOD
  
  /* goodG2B uses the GoodSource with the BadSink */
  void goodG2B_sink(twoints * data_array[])
  {
      twoints * data = data_array[2];
      /* POTENTIAL FLAW: Deallocate memory using delete - the source memory allocation function may
       * require a call to free() to deallocate the memory */
      delete data;
  }
  
  /* goodB2G uses the BadSource with the GoodSink */
  void goodB2G_sink(twoints * data_array[])
  {
      twoints * data = data_array[2];
      /* FIX: Deallocate the memory using free() */
      free(data);
  }
  
  #endif /* OMITGOOD */
  
  } // close namespace
  