text: /* TEMPLATE GENERATED TESTCASE FILE
  Filename: CWE415_Double_Free__malloc_free_int_64b.c
  Label Definition File: CWE415_Double_Free__malloc_free.label.xml
  Template File: sources-sinks-64b.tmpl.c
  */
  /*
   * @description
   * CWE: 415 Double Free
   * BadSource:  Allocate data using malloc() and Deallocate data using free()
   * GoodSource: Allocate data using malloc()
   * Sinks:
   *    GoodSink: do nothing
   *    BadSink : Deallocate data using free()
   * Flow Variant: 64 Data flow: void pointer to data passed from one function to another in different source files
   *
   * */
  
  #include "std_testcase.h"
  
  #include <wchar.h>
  
  #ifndef OMITBAD
  
  void CWE415_Double_Free__malloc_free_int_64b_badSink(void * dataVoidPtr)
  {
      /* cast void pointer to a pointer of the appropriate type */
      int * * dataPtr = (int * *)dataVoidPtr;
      /* dereference dataPtr into data */
      int * data = (*dataPtr);
      /* POTENTIAL FLAW: Possibly freeing memory twice */
      free(data);
  }
  
  #endif /* OMITBAD */
  
  #ifndef OMITGOOD
  
  /* goodG2B uses the GoodSource with the BadSink */
  void CWE415_Double_Free__malloc_free_int_64b_goodG2BSink(void * dataVoidPtr)
  {
      /* cast void pointer to a pointer of the appropriate type */
      int * * dataPtr = (int * *)dataVoidPtr;
      /* dereference dataPtr into data */
      int * data = (*dataPtr);
      /* POTENTIAL FLAW: Possibly freeing memory twice */
      free(data);
  }
  
  /* goodB2G uses the BadSource with the GoodSink */
  void CWE415_Double_Free__malloc_free_int_64b_goodB2GSink(void * dataVoidPtr)
  {
      /* cast void pointer to a pointer of the appropriate type */
      int * * dataPtr = (int * *)dataVoidPtr;
      /* dereference dataPtr into data */
      int * data = (*dataPtr);
      /* do nothing */
      /* FIX: Don't attempt to free the memory */
      ; /* empty statement needed for some flow variants */
  }
  
  #endif /* OMITGOOD */
  