text: /* TEMPLATE GENERATED TESTCASE FILE
  Filename: CWE762_Mismatched_Memory_Management_Routines__new_free_class_63b.cpp
  Label Definition File: CWE762_Mismatched_Memory_Management_Routines__new_free.label.xml
  Template File: sources-sinks-63b.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: 63 Data flow: pointer to data passed from one function to another in different source files
   *
   * */
  
  #include "std_testcase.h"
  
  namespace CWE762_Mismatched_Memory_Management_Routines__new_free_class_63
  {
  
  #ifndef OMITBAD
  
  void bad_sink(twointsclass * * data_ptr)
  {
      twointsclass * data = *data_ptr;
      /* 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 goodG2B_sink(twointsclass * * data_ptr)
  {
      twointsclass * data = *data_ptr;
      /* 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 goodB2G_sink(twointsclass * * data_ptr)
  {
      twointsclass * data = *data_ptr;
      /* FIX: Deallocate the memory using delete */
      delete data;
  }
  
  #endif /* OMITGOOD */
  
  } // close namespace
  