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