text: /* TEMPLATE GENERATED TESTCASE FILE
  Filename: CWE761_Free_Pointer_Not_at_Start_of_Buffer__wchar_t_console_82_goodB2G.cpp
  Label Definition File: CWE761_Free_Pointer_Not_at_Start_of_Buffer.label.xml
  Template File: source-sinks-82_goodB2G.tmpl.cpp
  */
  /*
   * @description
   * CWE: 761 Free Pointer not at Start of Buffer
   * BadSource: console Read input from the console
   * Sinks:
   *    GoodSink: free() memory correctly at the start of the buffer
   *    BadSink : free() memory not at the start of the buffer
   * Flow Variant: 82 Data flow: data passed in a parameter to an virtual method called via a pointer
   *
   * */
  #ifndef OMITGOOD
  
  #include "std_testcase.h"
  #include "CWE761_Free_Pointer_Not_at_Start_of_Buffer__wchar_t_console_82.h"
  
  #define SEARCH_CHAR L'S'
  
  namespace CWE761_Free_Pointer_Not_at_Start_of_Buffer__wchar_t_console_82
  {
  
  void CWE761_Free_Pointer_Not_at_Start_of_Buffer__wchar_t_console_82_goodB2G::action(wchar_t * data)
  {
      {
          size_t i;
          /* FIX: Use a loop variable to traverse through the string pointed to by data */
          for (i=0; i < wcslen(data); i++)
          {
              if (data[i] == SEARCH_CHAR)
              {
                  printLine("We have a match!");
                  break;
              }
          }
          free(data);
      }
  }
  
  }
  #endif /* OMITGOOD */
  