text: /* TEMPLATE GENERATED TESTCASE FILE
  Filename: CWE761_Free_Pointer_Not_at_Start_of_Buffer__char_file_82_bad.cpp
  Label Definition File: CWE761_Free_Pointer_Not_at_Start_of_Buffer.label.xml
  Template File: source-sinks-82_bad.tmpl.cpp
  */
  /*
   * @description
   * CWE: 761 Free Pointer not at Start of Buffer
   * BadSource: file Read input from a file
   * 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 OMITBAD
  
  #include "std_testcase.h"
  #include "CWE761_Free_Pointer_Not_at_Start_of_Buffer__char_file_82.h"
  
  #define SEARCH_CHAR 'S'
  
  namespace CWE761_Free_Pointer_Not_at_Start_of_Buffer__char_file_82
  {
  
  void CWE761_Free_Pointer_Not_at_Start_of_Buffer__char_file_82_bad::action(char * data)
  {
      /* FLAW: We are incrementing the pointer in the loop - this will cause us to free the
       * memory block not at the start of the buffer */
      for (; *data != '\0'; data++)
      {
          if (*data == SEARCH_CHAR)
          {
              printLine("We have a match!");
              break;
          }
      }
      free(data);
  }
  
  }
  #endif /* OMITBAD */
  