mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 595924: API change to go with Bug 598416 to fix crash r=mwu a=blocking2.0-betaN
This commit is contained in:
parent
d614df95fd
commit
94cfa6f633
@ -778,12 +778,6 @@ MOZ_WIN_MEM_TRY_BEGIN
|
|||||||
MOZ_WIN_MEM_TRY_CATCH(return nsnull)
|
MOZ_WIN_MEM_TRY_CATCH(return nsnull)
|
||||||
}
|
}
|
||||||
|
|
||||||
PRBool
|
|
||||||
nsZipArchive::CheckCRC(nsZipItem* aItem, const PRUint8* aItemData) {
|
|
||||||
PRUint32 crc = crc32(0, (const unsigned char*)aItemData, aItem->Size());
|
|
||||||
return crc == aItem->CRC32();
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------
|
//------------------------------------------
|
||||||
// nsZipArchive constructor and destructor
|
// nsZipArchive constructor and destructor
|
||||||
//------------------------------------------
|
//------------------------------------------
|
||||||
|
@ -221,8 +221,6 @@ public:
|
|||||||
*/
|
*/
|
||||||
const PRUint8* GetData(nsZipItem* aItem);
|
const PRUint8* GetData(nsZipItem* aItem);
|
||||||
|
|
||||||
PRBool CheckCRC(nsZipItem* aItem, const PRUint8* aData);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
//--- private members ---
|
//--- private members ---
|
||||||
|
|
||||||
@ -353,6 +351,25 @@ public:
|
|||||||
operator const T*() const {
|
operator const T*() const {
|
||||||
return Buffer();
|
return Buffer();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Relinquish ownership of zip member if compressed.
|
||||||
|
* Copy member into a new buffer if uncompressed.
|
||||||
|
* @return a buffer with whole zip member. It is caller's responsibility to free() it.
|
||||||
|
*/
|
||||||
|
T* Forget() {
|
||||||
|
if (!mReturnBuf)
|
||||||
|
return NULL;
|
||||||
|
// In uncompressed mmap case, give up buffer
|
||||||
|
if (mAutoBuf.get() == mReturnBuf) {
|
||||||
|
mReturnBuf = NULL;
|
||||||
|
return (T*) mAutoBuf.forget();
|
||||||
|
}
|
||||||
|
T *ret = (T*) malloc(Length());
|
||||||
|
memcpy(ret, mReturnBuf, Length());
|
||||||
|
mReturnBuf = NULL;
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class nsZipHandle {
|
class nsZipHandle {
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
*
|
*
|
||||||
* Contributor(s):
|
* Contributor(s):
|
||||||
* Benedict Hsieh <bhsieh@mozilla.com>
|
* Benedict Hsieh <bhsieh@mozilla.com>
|
||||||
|
* Taras Glek <tglek@mozilla.com>
|
||||||
*
|
*
|
||||||
* Alternatively, the contents of this file may be used under the terms of
|
* Alternatively, the contents of this file may be used under the terms of
|
||||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||||
@ -215,40 +216,26 @@ StartupCache::LoadArchive()
|
|||||||
nsresult
|
nsresult
|
||||||
StartupCache::GetBuffer(const char* id, char** outbuf, PRUint32* length)
|
StartupCache::GetBuffer(const char* id, char** outbuf, PRUint32* length)
|
||||||
{
|
{
|
||||||
char* data = NULL;
|
|
||||||
PRUint32 len;
|
|
||||||
|
|
||||||
if (!mStartupWriteInitiated) {
|
if (!mStartupWriteInitiated) {
|
||||||
CacheEntry* entry;
|
CacheEntry* entry;
|
||||||
nsDependentCString idStr(id);
|
nsDependentCString idStr(id);
|
||||||
mTable.Get(idStr, &entry);
|
mTable.Get(idStr, &entry);
|
||||||
if (entry) {
|
if (entry) {
|
||||||
data = entry->data;
|
*outbuf = new char[entry->size];
|
||||||
len = entry->size;
|
memcpy(*outbuf, entry->data, entry->size);
|
||||||
}
|
*length = entry->size;
|
||||||
}
|
|
||||||
|
|
||||||
if (!data && mArchive) {
|
|
||||||
nsZipItem* zipItem = mArchive->GetItem(id);
|
|
||||||
if (zipItem) {
|
|
||||||
const PRUint8* itemData = mArchive->GetData(zipItem);
|
|
||||||
if (!itemData || !mArchive->CheckCRC(zipItem, itemData)) {
|
|
||||||
NS_WARNING("StartupCache file corrupted!");
|
|
||||||
InvalidateCache();
|
|
||||||
return NS_ERROR_FILE_CORRUPTED;
|
|
||||||
}
|
|
||||||
|
|
||||||
len = zipItem->Size();
|
|
||||||
data = (char*) itemData;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (data) {
|
|
||||||
*outbuf = new char[len];
|
|
||||||
memcpy(*outbuf, data, len);
|
|
||||||
*length = len;
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mArchive) {
|
||||||
|
nsZipItemPtr<char> zipItem(mArchive, id, true);
|
||||||
|
if (zipItem) {
|
||||||
|
*outbuf = zipItem.Forget();
|
||||||
|
*length = zipItem.Length();
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return NS_ERROR_NOT_AVAILABLE;
|
return NS_ERROR_NOT_AVAILABLE;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user