func: static void goodB2G() void * data ; data = NULL; CWE122_Heap_Based_Buffer_Overflow__CWE135_84_goodB2G * goodB2GObject = new CWE122_Heap_Based_Buffer_Overflow__CWE135_84_goodB2G ( data ) ; CWE122_Heap_Based_Buffer_Overflow__CWE135_84_goodB2G::CWE122_Heap_Based_Buffer_Overflow__CWE135_84_goodB2G(void * dataCopy) data = dataCopy; wchar_t * dataBadBuffer = ( wchar_t * ) malloc ( 50 * sizeof ( wchar_t ) ) ; wmemset ( dataBadBuffer , L 'A' , 50 - 1 dataBadBuffer [ 50 - 1 ] = L '\0' data = ( void * ) dataBadBuffer; delete goodB2GObject CWE122_Heap_Based_Buffer_Overflow__CWE135_84_goodB2G::~CWE122_Heap_Based_Buffer_Overflow__CWE135_84_goodB2G() size_t dataLen = wcslen ( ( wchar_t * ) data ) ; void * dest = ( void * ) calloc ( dataLen + 1 , sizeof ( wchar_t ) ) ; memcpy ( dest , data , ( dataLen + 1 ) * sizeof ( wchar_t ) ); free ( dest ); 