зеркало из https://github.com/mozilla/gecko-dev.git
Bug 117119�BMP and ICO decoders should use ReadSegments, not Read
patch by cbiesinger@web.de r=pavlov sr=tor
This commit is contained in:
Родитель
8dead4d7a7
Коммит
81a81e92f1
|
@ -122,22 +122,19 @@ NS_IMETHODIMP nsBMPDecoder::Flush()
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_METHOD nsBMPDecoder::ReadSegCb(nsIInputStream* aIn, void* aClosure,
|
||||
const char* aFromRawSegment, PRUint32 aToOffset,
|
||||
PRUint32 aCount, PRUint32 *aWriteCount) {
|
||||
nsBMPDecoder *decoder = NS_REINTERPRET_CAST(nsBMPDecoder*, aClosure);
|
||||
*aWriteCount = aCount;
|
||||
return decoder->ProcessData(aFromRawSegment, aCount);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsBMPDecoder::WriteFrom(nsIInputStream *aInStr, PRUint32 aCount, PRUint32 *aRetval)
|
||||
{
|
||||
PR_LOG(gBMPLog, PR_LOG_DEBUG, ("nsBMPDecoder::WriteFrom(%p, %lu, %p)\n", aInStr, aCount, aRetval));
|
||||
|
||||
char* buffer = new char[aCount];
|
||||
if (!buffer) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
unsigned int realCount = aCount;
|
||||
nsresult rv = aInStr->Read(buffer, aCount, &realCount);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
*aRetval = realCount;
|
||||
|
||||
rv = ProcessData(buffer, realCount);
|
||||
delete []buffer;
|
||||
return rv;
|
||||
return aInStr->ReadSegments(ReadSegCb, this, aCount, aRetval);
|
||||
}
|
||||
|
||||
// ----------------------------------------
|
||||
|
|
|
@ -125,6 +125,11 @@ public:
|
|||
virtual ~nsBMPDecoder();
|
||||
|
||||
private:
|
||||
/** Callback for ReadSegments to avoid copying the data */
|
||||
static NS_METHOD ReadSegCb(nsIInputStream* aIn, void* aClosure,
|
||||
const char* aFromRawSegment, PRUint32 aToOffset,
|
||||
PRUint32 aCount, PRUint32 *aWriteCount);
|
||||
|
||||
/** Processes the data.
|
||||
* @param aBuffer Data to process.
|
||||
* @oaram count Number of bytes in mBuffer */
|
||||
|
|
|
@ -191,21 +191,18 @@ NS_IMETHODIMP nsICODecoder::Flush()
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_METHOD nsICODecoder::ReadSegCb(nsIInputStream* aIn, void* aClosure,
|
||||
const char* aFromRawSegment, PRUint32 aToOffset,
|
||||
PRUint32 aCount, PRUint32 *aWriteCount) {
|
||||
nsICODecoder *decoder = NS_REINTERPRET_CAST(nsICODecoder*, aClosure);
|
||||
*aWriteCount = aCount;
|
||||
return decoder->ProcessData(aFromRawSegment, aCount);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsICODecoder::WriteFrom(nsIInputStream *aInStr, PRUint32 aCount, PRUint32 *aRetval)
|
||||
{
|
||||
char* buffer = new char[aCount];
|
||||
if (!buffer)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
unsigned int realCount = aCount;
|
||||
nsresult rv = aInStr->Read(buffer, aCount, &realCount);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
*aRetval = realCount;
|
||||
|
||||
rv = ProcessData(buffer, realCount);
|
||||
delete []buffer;
|
||||
return rv;
|
||||
return aInStr->ReadSegments(ReadSegCb, this, aCount, aRetval);
|
||||
}
|
||||
|
||||
nsresult nsICODecoder::ProcessData(const char* aBuffer, PRUint32 aCount) {
|
||||
|
|
|
@ -80,6 +80,11 @@ public:
|
|||
virtual ~nsICODecoder();
|
||||
|
||||
private:
|
||||
/** Callback for ReadSegments to avoid copying the data */
|
||||
static NS_METHOD ReadSegCb(nsIInputStream* aIn, void* aClosure,
|
||||
const char* aFromRawSegment, PRUint32 aToOffset,
|
||||
PRUint32 aCount, PRUint32 *aWriteCount);
|
||||
|
||||
// Private helper methods
|
||||
nsresult ProcessData(const char* aBuffer, PRUint32 aCount);
|
||||
void ProcessDirEntry();
|
||||
|
|
Загрузка…
Ссылка в новой задаче