corrupt heap in graphedt.exe with source filter.

corrupt heap in graphedt.exe with source filter.

Post by UGhpbCBpbi » Sun, 11 Jun 2006 03:51:02


i am writing a source filter that supports IFileSourceFilter. it is a
barebones filter right now - i.e. it doesn't do anything except ask for a
filename.

in visual studio, I am using "graphedt.exe" as the debugging command. I run
graphedt, and then I try to add my source filter to the graph.

when I attempt to run, i set a breakpoint inside of
IFileSourceFilter::GetCurFile() (actually CSourceFilter::GetCurFile() of
course). I get in there and continue (F5), and visual studio (.net 2005 btw)
pops up a dialog that says:

Windows has triggered a breakpoint in graphedt.exe

This may be due to a corruption of the heap and indicates a bug in
graphedt.exe or any of the DLLs it has loaded.

The output window may have more diagnostic information.

[ Break ] [ Continue ]

My output window looks like this:

If I continue it seems to be okay. I am not doing anything special in my
GetCurFile() call either.

/* virtual */ STDMETHODIMP CSourceFilter::GetCurFile(LPOLESTR* ppszFileName,
AM_MEDIA_TYPE* pmt)
{
CheckPointer(ppszFileName, E_POINTER);

int buflen = m_wstrFileName.length() + 1;
LPOLESTR oszFileName = LPOLESTR(::CoTaskMemAlloc(buflen));
errno_t err = wcscpy_s(oszFileName, buflen, m_wstrFileName.c_str());
if (0 != err)
{
return E_FAIL;
}
*ppszFileName = oszFileName;

return S_OK;
}

Thoughts?
 
 
 

corrupt heap in graphedt.exe with source filter.

Post by UGhpbCBpbi » Sun, 11 Jun 2006 04:00:01

nevermind, i'm an idiot.

int buflen = sizeof(wchar_t) * (m_wstrFileName.length() + 1);

-phil

 
 
 

corrupt heap in graphedt.exe with source filter.

Post by UGhpbCBpbi » Sun, 11 Jun 2006 04:04:02

/* virtual */ STDMETHODIMP CSourceFilter::GetCurFile(LPOLESTR* ppszFileName,
AM_MEDIA_TYPE* pmt)
{
CheckPointer(ppszFileName, E_POINTER);

int buflen = m_wstrFileName.length() + 1;
LPOLESTR oszFileName = LPOLESTR(::CoTaskMemAlloc(buflen *
sizeof(wchar_t)));
errno_t err = wcscpy_s(oszFileName, buflen, m_wstrFileName.c_str());
if (0 != err)
{
return E_FAIL;
}
*ppszFileName = oszFileName;

return S_OK;
}