Fixes bug 89397. This fixes a problem where byteranges which start at offest 0 do not reset the mPosition. This cause byte to be written at random places in the file.

r=peterl, r=av, sr=attinasi
This commit is contained in:
dougt%netscape.com 2001-07-05 19:33:09 +00:00
parent 0929067509
commit fc68b1ad26
4 changed files with 16 additions and 6 deletions

View File

@ -56,6 +56,7 @@ ns4xPluginStreamListener::ns4xPluginStreamListener(nsIPluginInstance* inst,
mInst = (ns4xPluginInstance*) inst;
mStreamBuffer=nsnull;
mPosition = 0;
mCurrentStreamOffset = -1;
// Initialize the 4.x interface structure
memset(&mNPStream, 0, sizeof(mNPStream));
@ -291,10 +292,13 @@ ns4xPluginStreamListener::OnDataAvailable(nsIPluginStreamInfo* pluginInfo,
PRUint32 leftToRead = 0; // just in case OnDataaAvail tries to overflow our buffer
PRBool createdHere = PR_FALSE; // we did malloc in locally, so we must free locally
// we are getting a range request, reset mPosition since postion passed to plugin will
// be relative to the absolute position of the file.
if (sourceOffset != 0)
// if we are getting a range request, reset mPosition.
if (sourceOffset != mCurrentStreamOffset ||
mCurrentStreamOffset == -1 )
{
mPosition = 0;
mCurrentStreamOffset = sourceOffset;
}
pluginInfo->GetURL(&mNPStream.url);
pluginInfo->GetLastModified((PRUint32*)&(mNPStream.lastmodified));

View File

@ -55,6 +55,7 @@ protected:
ns4xPluginInstance* mInst;
NPStream mNPStream;
PRUint32 mPosition;
PRUint32 mCurrentStreamOffset;
nsPluginStreamType mStreamType;
public:

View File

@ -56,6 +56,7 @@ ns4xPluginStreamListener::ns4xPluginStreamListener(nsIPluginInstance* inst,
mInst = (ns4xPluginInstance*) inst;
mStreamBuffer=nsnull;
mPosition = 0;
mCurrentStreamOffset = -1;
// Initialize the 4.x interface structure
memset(&mNPStream, 0, sizeof(mNPStream));
@ -291,10 +292,13 @@ ns4xPluginStreamListener::OnDataAvailable(nsIPluginStreamInfo* pluginInfo,
PRUint32 leftToRead = 0; // just in case OnDataaAvail tries to overflow our buffer
PRBool createdHere = PR_FALSE; // we did malloc in locally, so we must free locally
// we are getting a range request, reset mPosition since postion passed to plugin will
// be relative to the absolute position of the file.
if (sourceOffset != 0)
// if we are getting a range request, reset mPosition.
if (sourceOffset != mCurrentStreamOffset ||
mCurrentStreamOffset == -1 )
{
mPosition = 0;
mCurrentStreamOffset = sourceOffset;
}
pluginInfo->GetURL(&mNPStream.url);
pluginInfo->GetLastModified((PRUint32*)&(mNPStream.lastmodified));

View File

@ -55,6 +55,7 @@ protected:
ns4xPluginInstance* mInst;
NPStream mNPStream;
PRUint32 mPosition;
PRUint32 mCurrentStreamOffset;
nsPluginStreamType mStreamType;
public: