Access violation while pushing newnode on list
Hi all,
I have problem with pushing the node on the list.
my program is as follows
Code:
struct LinkFiles
{
int count;
int index;
wchar_t * filePath;
wchar_t * fileName;
};
uint64_t length=0;
struct LinkFiles newnode ;
newnode.count = stats.f_nlink - 1;
newnode.fileIndex=index;
newnode.fileName=(vfm_char_t*)malloc(wcslen(name.c_str())+1);
if (NULL != newnode.fileName)
{
wcsncpy(newnode.fileName,name.c_str(), wcslen(name.c_str())) ;
}
else
{
wprintf(L"\n\n CopyIndex : newnode.fileName is null ");
goto end ;
}
length = wcslen(name.c_str());
newnode.fileName[length]=L'\0' ;
newnode.filePath=(vfm_char_t*)malloc(wcslen(path.c_str())+1);
wprintf(L"\n\n The strlen of path is <%d> ",wcslen (path.c_str()));
if (NULL != newnode.filePath)
{
wcsncpy(newnode.filePath , path.c_str(),wcslen (path.c_str()));
}
else
{
wprintf(L"\n\n CopyIndex : newnode.filePath is null ");
goto end;
}
length=wcslen(path.c_str());
newnode.filePath[length]=L'\0' ;
try
{
g_linkFilesList.push_back(newnode);
}
catch (...)
{
wprintf(L"\n\n CopyIndex : Error while pushing newnode on list ");
}
In this , i get an error "Access Violation : writing to location 0x00000000 "
The newnode.filePath and newnode.fileName are valid .
Please response asap.