summaryrefslogtreecommitdiffstats
path: root/xpcom
diff options
context:
space:
mode:
authorMoonchild <moonchild@palemoon.org>2020-11-20 09:47:03 +0000
committerMoonchild <moonchild@palemoon.org>2020-11-20 09:47:03 +0000
commit5165ed02285315cc0bed7977c7bac6d0a90ca43c (patch)
tree9b761a21eb924915e51c2d803208e6c01b505a45 /xpcom
parente1db27e19989db11fef70f439cf95821316535b3 (diff)
parentca9abcdf1702c37bf00048dab3f460b2252873a3 (diff)
downloadUXP-5165ed02285315cc0bed7977c7bac6d0a90ca43c.tar
UXP-5165ed02285315cc0bed7977c7bac6d0a90ca43c.tar.gz
UXP-5165ed02285315cc0bed7977c7bac6d0a90ca43c.tar.lz
UXP-5165ed02285315cc0bed7977c7bac6d0a90ca43c.tar.xz
UXP-5165ed02285315cc0bed7977c7bac6d0a90ca43c.zip
Merge branch 'redwood' into releaseRELBASE_20201124RELBASE_20201120RC_20201120
Diffstat (limited to 'xpcom')
-rw-r--r--xpcom/glue/nsTArray-inl.h26
-rw-r--r--xpcom/io/SpecialSystemDirectory.cpp4
2 files changed, 23 insertions, 7 deletions
diff --git a/xpcom/glue/nsTArray-inl.h b/xpcom/glue/nsTArray-inl.h
index 7e667a327..6fdfdcb7c 100644
--- a/xpcom/glue/nsTArray-inl.h
+++ b/xpcom/glue/nsTArray-inl.h
@@ -249,12 +249,28 @@ nsTArray_base<Alloc, Copy>::ShrinkCapacity(size_type aElemSize,
return;
}
- size_type size = sizeof(Header) + length * aElemSize;
- void* ptr = nsTArrayFallibleAllocator::Realloc(mHdr, size);
- if (!ptr) {
- return;
+ size_type newSize = sizeof(Header) + length * aElemSize;
+
+ Header* newHeader;
+ if (!Copy::allowRealloc) {
+ // Malloc() and copy
+ newHeader = static_cast<Header*>(nsTArrayFallibleAllocator::Malloc(newSize));
+ if (!newHeader) {
+ return;
+ }
+
+ Copy::MoveNonOverlappingRegionWithHeader(newHeader, mHdr, Length(), aElemSize);
+
+ nsTArrayFallibleAllocator::Free(mHdr);
+ } else {
+ // Realloc() existing data
+ newHeader = static_cast<Header*>(nsTArrayFallibleAllocator::Realloc(mHdr, newSize));
+ if (!newHeader) {
+ return;
+ }
}
- mHdr = static_cast<Header*>(ptr);
+
+ mHdr = newHeader;
mHdr->mCapacity = length;
}
diff --git a/xpcom/io/SpecialSystemDirectory.cpp b/xpcom/io/SpecialSystemDirectory.cpp
index c174b4ac7..1c020c426 100644
--- a/xpcom/io/SpecialSystemDirectory.cpp
+++ b/xpcom/io/SpecialSystemDirectory.cpp
@@ -76,9 +76,9 @@ GetWindowsFolder(int aFolder, nsIFile** aFile)
{
WCHAR path_orig[MAX_PATH + 3];
WCHAR* path = path_orig + 1;
- HRESULT result = SHGetSpecialFolderPathW(nullptr, path, aFolder, true);
+ BOOL result = SHGetSpecialFolderPathW(nullptr, path, aFolder, true);
- if (!SUCCEEDED(result)) {
+ if (!result) {
return NS_ERROR_FAILURE;
}