Bug 1418164 - Don't leave uninitialized values lying around. r=froydnj
The users of WriteSegmentFun and ReadSegmentFun read the final out parameter
whether or not the function returns an error. We should make sure to fill it
in with a sane value.
MozReview-Commit-ID: GWDS8gENUMB
--- a/xpcom/io/nsStreamUtils.cpp
+++ b/xpcom/io/nsStreamUtils.cpp
@@ -739,17 +739,18 @@ TestInputStream(nsIInputStream* aInStr,
void* aClosure,
const char* aBuffer,
uint32_t aOffset,
uint32_t aCount,
uint32_t* aCountWritten)
{
bool* result = static_cast<bool*>(aClosure);
*result = true;
- return NS_ERROR_ABORT; // don't call me anymore
+ *aCountWritten = 0;
+ return NS_ERROR_ABORT; // don't call me anymore
}
bool
NS_InputStreamIsBuffered(nsIInputStream* aStream)
{
nsCOMPtr<nsIBufferedInputStream> bufferedIn = do_QueryInterface(aStream);
if (bufferedIn) {
return true;
@@ -766,17 +767,18 @@ TestOutputStream(nsIOutputStream* aOutSt
void* aClosure,
char* aBuffer,
uint32_t aOffset,
uint32_t aCount,
uint32_t* aCountRead)
{
bool* result = static_cast<bool*>(aClosure);
*result = true;
- return NS_ERROR_ABORT; // don't call me anymore
+ *aCountRead = 0;
+ return NS_ERROR_ABORT; // don't call me anymore
}
bool
NS_OutputStreamIsBuffered(nsIOutputStream* aStream)
{
nsCOMPtr<nsIBufferedOutputStream> bufferedOut = do_QueryInterface(aStream);
if (bufferedOut) {
return true;