diff --git a/js/src/vm/Stopwatch.cpp b/js/src/vm/Stopwatch.cpp index c06724a8edb..faa37f765f7 100644 --- a/js/src/vm/Stopwatch.cpp +++ b/js/src/vm/Stopwatch.cpp @@ -221,8 +221,10 @@ AutoStopwatch::AutoStopwatch(JSContext* cx MOZ_GUARD_OBJECT_NOTIFIER_PARAM_IN_IM } for (auto group = groups->begin(); group < groups->end(); group++) { auto acquired = acquireGroup(*group); - if (acquired) - groups_.append(acquired); + if (acquired) { + if (!groups_.append(acquired)) + MOZ_CRASH(); + } } if (groups_.length() == 0) { // We are not in charge of monitoring anything. diff --git a/toolkit/components/perfmonitoring/nsPerformanceStats.cpp b/toolkit/components/perfmonitoring/nsPerformanceStats.cpp index d2c759943a2..187164e8a04 100644 --- a/toolkit/components/perfmonitoring/nsPerformanceStats.cpp +++ b/toolkit/components/perfmonitoring/nsPerformanceStats.cpp @@ -164,7 +164,9 @@ nsPerformanceObservationTarget::SetTarget(nsPerformanceGroupDetails* details) { NS_IMETHODIMP nsPerformanceObservationTarget::AddJankObserver(nsIPerformanceObserver* observer) { - mObservers.append(observer); + if (!mObservers.append(observer)) { + MOZ_CRASH(); + } return NS_OK; }; @@ -188,7 +190,9 @@ void nsPerformanceObservationTarget::NotifyJankObservers(nsIPerformanceGroupDetails* source, nsIPerformanceAlert* gravity) { // Copy the vector to make sure that it won't change under our feet. mozilla::Vector> observers; - observers.appendAll(mObservers); + if (!observers.appendAll(mObservers)) { + MOZ_CRASH(); + } // Now actually notify. for (auto iter = observers.begin(), end = observers.end(); iter < end; ++iter) { @@ -733,7 +737,9 @@ nsPerformanceStatsService::Dispose() // not modify the hashtable while iterating it. GroupVector groups; for (auto iter = mGroups.Iter(); !iter.Done(); iter.Next()) { - groups.append(iter.Get()->GetKey()); + if (!groups.append(iter.Get()->GetKey())) { + MOZ_CRASH(); + } } for (auto iter = groups.begin(), end = groups.end(); iter < end; ++iter) { RefPtr group = *iter; @@ -1007,7 +1013,10 @@ nsPerformanceStatsService::GetPerformanceGroups(JSContext* cx, JSGroupVector& ou } // All compartments belong to the top group. - out.append(mTopGroup); + if (!out.append(mTopGroup)) { + JS_ReportOutOfMemory(cx); + return false; + } nsAutoString name; CompartmentName(cx, global, name); @@ -1032,7 +1041,10 @@ nsPerformanceStatsService::GetPerformanceGroups(JSContext* cx, JSGroupVector& ou nsPerformanceGroup::GroupScope::ADDON) ); } - out.append(entry->GetGroup()); + if (!out.append(entry->GetGroup())) { + JS_ReportOutOfMemory(cx); + return false; + } } // Find out if the compartment is executed by a window. If so, its @@ -1054,7 +1066,10 @@ nsPerformanceStatsService::GetPerformanceGroups(JSContext* cx, JSGroupVector& ou nsPerformanceGroup::GroupScope::WINDOW) ); } - out.append(entry->GetGroup()); + if (!out.append(entry->GetGroup())) { + JS_ReportOutOfMemory(cx); + return false; + } } // All compartments have their own group. @@ -1063,7 +1078,10 @@ nsPerformanceStatsService::GetPerformanceGroups(JSContext* cx, JSGroupVector& ou name, addonId, windowId, mProcessId, isSystem, nsPerformanceGroup::GroupScope::COMPARTMENT); - out.append(group); + if (!out.append(group)) { + JS_ReportOutOfMemory(cx); + return false; + } return true; } @@ -1190,8 +1208,9 @@ nsPerformanceStatsService::CommitGroup(uint64_t iteration, if (totalTimeDelta >= mJankAlertThreshold) { if (!group->HasPendingAlert()) { - group->SetHasPendingAlert(true); - mPendingAlerts.append(group); + if (mPendingAlerts.append(group)) { + group->SetHasPendingAlert(true); + } return; } } diff --git a/toolkit/components/telemetry/Telemetry.cpp b/toolkit/components/telemetry/Telemetry.cpp index 3a57c38f0ff..7387e280d30 100644 --- a/toolkit/components/telemetry/Telemetry.cpp +++ b/toolkit/components/telemetry/Telemetry.cpp @@ -16,6 +16,7 @@ #include "mozilla/DebugOnly.h" #include "mozilla/Likely.h" #include "mozilla/MathAlgorithms.h" +#include "mozilla/unused.h" #include "base/histogram.h" #include "base/pickle.h" @@ -3669,7 +3670,8 @@ TelemetryImpl::RecordThreadHangStats(Telemetry::ThreadHangStats& aStats) MutexAutoLock autoLock(sTelemetry->mThreadHangStatsMutex); - sTelemetry->mThreadHangStats.append(Move(aStats)); + // Ignore OOM. + mozilla::Unused << sTelemetry->mThreadHangStats.append(Move(aStats)); } NS_IMPL_ISUPPORTS(TelemetryImpl, nsITelemetry, nsIMemoryReporter) diff --git a/toolkit/components/telemetry/ThreadHangStats.h b/toolkit/components/telemetry/ThreadHangStats.h index 6ab077fa62c..60aa680c87d 100644 --- a/toolkit/components/telemetry/ThreadHangStats.h +++ b/toolkit/components/telemetry/ThreadHangStats.h @@ -187,7 +187,9 @@ public: void Add(PRIntervalTime aTime, HangMonitor::HangAnnotationsPtr aAnnotations) { TimeHistogram::Add(aTime); if (aAnnotations) { - mAnnotations.append(Move(aAnnotations)); + if (!mAnnotations.append(Move(aAnnotations))) { + MOZ_CRASH(); + } } } }; diff --git a/xpcom/threads/BackgroundHangMonitor.cpp b/xpcom/threads/BackgroundHangMonitor.cpp index 3b5ccc4c4bf..06d39b7f282 100644 --- a/xpcom/threads/BackgroundHangMonitor.cpp +++ b/xpcom/threads/BackgroundHangMonitor.cpp @@ -437,7 +437,9 @@ BackgroundHangThread::ReportHang(PRIntervalTime aHangTime) } // Add new histogram newHistogram.Add(aHangTime, Move(mAnnotations)); - mStats.mHangs.append(Move(newHistogram)); + if (!mStats.mHangs.append(Move(newHistogram))) { + MOZ_CRASH(); + } return mStats.mHangs.back(); }