backout 2bb432c47170 for debug asserts

This commit is contained in:
Trevor Saunders 2012-12-05 04:19:33 -05:00
Родитель b63355129b
Коммит bac28f7e18
5 изменённых файлов: 34 добавлений и 17 удалений

Просмотреть файл

@ -161,6 +161,7 @@
#include "nsIJARChannel.h" #include "nsIJARChannel.h"
#include "prlog.h" #include "prlog.h"
#include "prmem.h"
#include "nsISelectionDisplay.h" #include "nsISelectionDisplay.h"

Просмотреть файл

@ -32,6 +32,7 @@
// Helper Classes // Helper Classes
#include "nsXPIDLString.h" #include "nsXPIDLString.h"
#include "nsJSUtils.h" #include "nsJSUtils.h"
#include "prmem.h"
#include "jsapi.h" // for JSAutoRequest #include "jsapi.h" // for JSAutoRequest
#include "jsdbgapi.h" // for JS_ClearWatchPointsForObject #include "jsdbgapi.h" // for JS_ClearWatchPointsForObject
#include "jsfriendapi.h" // for JS_GetGlobalForFrame #include "jsfriendapi.h" // for JS_GetGlobalForFrame

Просмотреть файл

@ -49,6 +49,7 @@
#include "nsIObjectInputStream.h" #include "nsIObjectInputStream.h"
#include "nsIObjectOutputStream.h" #include "nsIObjectOutputStream.h"
#include "nsDOMScriptObjectHolder.h" #include "nsDOMScriptObjectHolder.h"
#include "prmem.h"
#include "WrapperFactory.h" #include "WrapperFactory.h"
#include "nsGlobalWindow.h" #include "nsGlobalWindow.h"
#include "nsScriptNameSpaceManager.h" #include "nsScriptNameSpaceManager.h"
@ -4105,19 +4106,25 @@ public:
protected: protected:
JSContext *mContext; JSContext *mContext;
FallibleTArray<jsval> mArgv; jsval *mArgv;
uint32_t mArgc;
}; };
nsJSArgArray::nsJSArgArray(JSContext *aContext, uint32_t argc, jsval *argv, nsJSArgArray::nsJSArgArray(JSContext *aContext, uint32_t argc, jsval *argv,
nsresult *prv) : nsresult *prv) :
mContext(aContext) mContext(aContext),
mArgv(nullptr),
mArgc(argc)
{ {
// copy the array - we don't know its lifetime, and ours is tied to xpcom // copy the array - we don't know its lifetime, and ours is tied to xpcom
// refcounting. Alloc zero'd array so cleanup etc is safe. // refcounting. Alloc zero'd array so cleanup etc is safe.
if (!mArgv.EnsureLengthAtLeast(argc)) { if (argc) {
mArgv = (jsval *) PR_CALLOC(argc * sizeof(jsval));
if (!mArgv) {
*prv = NS_ERROR_OUT_OF_MEMORY; *prv = NS_ERROR_OUT_OF_MEMORY;
return; return;
} }
}
// Callers are allowed to pass in a null argv even for argc > 0. They can // Callers are allowed to pass in a null argv even for argc > 0. They can
// then use GetArgs to initialize the values. // then use GetArgs to initialize the values.
@ -4141,10 +4148,13 @@ nsJSArgArray::~nsJSArgArray()
void void
nsJSArgArray::ReleaseJSObjects() nsJSArgArray::ReleaseJSObjects()
{ {
if (!mArgv.IsEmpty()) if (mArgv) {
PR_DELETE(mArgv);
}
if (mArgc > 0) {
mArgc = 0;
NS_DROP_JS_OBJECTS(this, nsJSArgArray); NS_DROP_JS_OBJECTS(this, nsJSArgArray);
}
mArgv.Clear();
} }
// QueryInterface implementation for nsJSArgArray // QueryInterface implementation for nsJSArgArray
@ -4157,10 +4167,12 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(nsJSArgArray)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN(nsJSArgArray) NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN(nsJSArgArray)
uint32_t length = tmp->mArgv.Length(); jsval *argv = tmp->mArgv;
for (uint32_t i = 0; i < length; i++) { if (argv) {
if (JSVAL_IS_GCTHING(tmp->mArgv[i])) { jsval *end;
NS_IMPL_CYCLE_COLLECTION_TRACE_JS_CALLBACK(JSVAL_TO_GCTHING(tmp->mArgv[i]), for (end = argv + tmp->mArgc; argv < end; ++argv) {
if (JSVAL_IS_GCTHING(*argv))
NS_IMPL_CYCLE_COLLECTION_TRACE_JS_CALLBACK(JSVAL_TO_GCTHING(*argv),
"mArgv[i]") "mArgv[i]")
} }
} }
@ -4178,15 +4190,15 @@ NS_IMPL_CYCLE_COLLECTING_RELEASE(nsJSArgArray)
nsresult nsresult
nsJSArgArray::GetArgs(uint32_t *argc, void **argv) nsJSArgArray::GetArgs(uint32_t *argc, void **argv)
{ {
*argv = (void *)mArgv.Elements(); *argv = (void *)mArgv;
*argc = mArgv.Length(); *argc = mArgc;
return NS_OK; return NS_OK;
} }
// nsIArray impl // nsIArray impl
NS_IMETHODIMP nsJSArgArray::GetLength(uint32_t *aLength) NS_IMETHODIMP nsJSArgArray::GetLength(uint32_t *aLength)
{ {
*aLength = mArgv.Length(); *aLength = mArgc;
return NS_OK; return NS_OK;
} }
@ -4194,7 +4206,7 @@ NS_IMETHODIMP nsJSArgArray::GetLength(uint32_t *aLength)
NS_IMETHODIMP nsJSArgArray::QueryElementAt(uint32_t index, const nsIID & uuid, void * *result) NS_IMETHODIMP nsJSArgArray::QueryElementAt(uint32_t index, const nsIID & uuid, void * *result)
{ {
*result = nullptr; *result = nullptr;
if (index >= mArgv.Length()) if (index >= mArgc)
return NS_ERROR_INVALID_ARG; return NS_ERROR_INVALID_ARG;
if (uuid.Equals(NS_GET_IID(nsIVariant)) || uuid.Equals(NS_GET_IID(nsISupports))) { if (uuid.Equals(NS_GET_IID(nsIVariant)) || uuid.Equals(NS_GET_IID(nsISupports))) {

Просмотреть файл

@ -191,7 +191,7 @@ ArchiveReaderZipEvent::Exec()
} }
// Read the name: // Read the name:
nsAutoArrayPtr<char> filename(new char[filenameLen + 1]); char* filename = (char*)PR_Malloc(filenameLen + 1);
rv = inputStream->Read(filename, filenameLen, &ret); rv = inputStream->Read(filename, filenameLen, &ret);
if (NS_FAILED(rv) || ret != filenameLen) { if (NS_FAILED(rv) || ret != filenameLen) {
return RunShare(NS_ERROR_UNEXPECTED); return RunShare(NS_ERROR_UNEXPECTED);
@ -204,6 +204,8 @@ ArchiveReaderZipEvent::Exec()
mFileList.AppendElement(new ArchiveZipItem(filename, centralStruct, mOptions)); mFileList.AppendElement(new ArchiveZipItem(filename, centralStruct, mOptions));
} }
PR_Free(filename);
// Ignore the rest // Ignore the rest
seekableStream->Seek(nsISeekableStream::NS_SEEK_CUR, extraLen + commentLen); seekableStream->Seek(nsISeekableStream::NS_SEEK_CUR, extraLen + commentLen);
} }

Просмотреть файл

@ -8,6 +8,7 @@
#include "nsCRT.h" #include "nsCRT.h"
#include "nsIFile.h" #include "nsIFile.h"
#include "nsDependentString.h" #include "nsDependentString.h"
#include "prmem.h"
#include "nsArrayEnumerator.h" #include "nsArrayEnumerator.h"
#include "mozilla/Preferences.h" #include "mozilla/Preferences.h"