Commit c3697207 authored by Nika Layzell's avatar Nika Layzell
Browse files

Bug 1740797 - Use an owning string when serializing nsStringInputStream as a pipe, r=smaug,a=dsmith

parent db952581
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -432,6 +432,15 @@ void nsStringInputStream::SerializeInternal(InputStreamParams& aParams,
  *aSizeUsed = 0;

  if (Length() >= aMaxSize) {
    // If the input stream is non-owning (i.e. it was initialized with
    // `ShareData`), request mutable access to `mData`, forcing our string to
    // take ownership so that it doesn't go away while async copying.
    if (!mArray && !(mData.GetDataFlags() & (nsCString::DataFlags::REFCOUNTED |
                                             nsCString::DataFlags::OWNED |
                                             nsCString::DataFlags::LITERAL))) {
      mData.BeginWriting();
    }

    InputStreamHelper::SerializeInputStreamAsPipe(this, aParams, aDelayedStart,
                                                  aManager);
    return;