text: /* TEMPLATE GENERATED TESTCASE FILE
  Filename: CWE690_NULL_Deref_From_Return__int64_t_malloc_72b.cpp
  Label Definition File: CWE690_NULL_Deref_From_Return.free.label.xml
  Template File: source-sinks-72b.tmpl.cpp
  */
  /*
   * @description
   * CWE: 690 Unchecked Return Value To NULL Pointer
   * BadSource: malloc Allocate data using malloc()
   * Sinks:
   *    GoodSink: Check to see if the data allocation failed and if not, use data
   *    BadSink : Don't check for NULL and use data
   * 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>
  
  #include <wchar.h>
  
  using namespace std;
  
  namespace CWE690_NULL_Deref_From_Return__int64_t_malloc_72
  {
  
  #ifndef OMITBAD
  
  void badSink(vector<int64_t *> dataVector)
  {
      /* copy data out of dataVector */
      int64_t * data = dataVector[2];
      /* FLAW: Initialize memory buffer without checking to see if the memory allocation function failed */
      data[0] = 5LL;
      printLongLongLine(data[0]);
      free(data);
  }
  
  #endif /* OMITBAD */
  
  #ifndef OMITGOOD
  
  /* goodB2G uses the BadSource with the GoodSink */
  void goodB2GSink(vector<int64_t *> dataVector)
  {
      int64_t * data = dataVector[2];
      /* FIX: Check to see if the memory allocation function was successful before initializing the memory buffer */
      if (data != NULL)
      {
          data[0] = 5LL;
          printLongLongLine(data[0]);
          free(data);
      }
  }
  
  #endif /* OMITGOOD */
  
  } /* close namespace */
  