Hi,

I'm trying to use the NS_NewCharInputStream() call to create an
nsIInputStream from a standard C-string.  The creation process seems to go
fine, but when I attempt to call Read() on the resulting stream, I get an
assertion:

###!!! ASSERTION: Write to a const string: 'PR_FALSE', file
c:\dev\projects\c++\xpconnect\mozilla\xpcom\io\nsIStringStream.cpp, line 276
###!!! Break: at file
c:\dev\projects\c++\xpconnect\mozilla\xpcom\io\nsIStringStream.cpp, line 276

Now, this might not be too strange except for the fact that the assertion is
in the write() method of BasicStringImpl!  So, I stepped into the code from
my call to Read() and it promptly placed me in BasicStringImpl's Write()
method.  Very odd since nowhere does Read() ever call Write()!  Does anyone
have any ideas?  Here are the vital statistics:

Platform : Windows 2000
Compiler : VC++ 6.0
XPCOM build : Standalone XPCOM.  I pulled down the latest from CVS on
2/28/20001.

My code follows.

Thanks in advance,
Todd

...
nsresult nsr;
nsCOMPtr<nsIInputStream> cptrStream;

nsr = NS_NewCharInputStream(getter_AddRefs(cptrStream), "Hmmmm");

if (NS_FAILED(nsr))
{
    return nsr;
}

PRUint32 ulLength;
char* pszBuffer = new char[6];

nsr = cptrStream->Read(pszBuffer, ulLength, &ulLength);

if (NS_FAILED(nsr))
{
    return nsr;
}
...



Reply via email to