Commit 97a8914b authored by Dan Minor's avatar Dan Minor
Browse files

Bug 1858496 - Crash on OOM in ICU; a=diannaS

We're seeing inconsistent handling of OOMs in the ICU library. This
patch changes the behaviour to crash on OOM rather than allowing
ICU to handle the allocation failure. The inconsistent handling in ICU
could lead to ICU being in an inconsistent state which could in turn
cause security problems. The safer alternative is to crash, but it's
possible this will lead to too high of crash rate.

Original Revision: https://phabricator.services.mozilla.com/D191892

Differential Revision: https://phabricator.services.mozilla.com/D202498
parent 9e1762eb
Loading
Loading
Loading
Loading
+10 −2
Original line number Diff line number Diff line
@@ -164,11 +164,19 @@ class ICUReporter final : public nsIMemoryReporter,
  NS_DECL_ISUPPORTS

  static void* Alloc(const void*, size_t aSize) {
    return CountingMalloc(aSize);
    void* result = CountingMalloc(aSize);
    if (result == nullptr) {
      MOZ_CRASH("Ran out of memory while allocating for ICU");
    }
    return result;
  }

  static void* Realloc(const void*, void* aPtr, size_t aSize) {
    return CountingRealloc(aPtr, aSize);
    void* result = CountingRealloc(aPtr, aSize);
    if (result == nullptr) {
      MOZ_CRASH("Ran out of memory while reallocating for ICU");
    }
    return result;
  }

  static void Free(const void*, void* aPtr) { return CountingFree(aPtr); }