Title: [211579] trunk/Source/WebCore
Revision
211579
Author
bfulg...@apple.com
Date
2017-02-02 11:33:09 -0800 (Thu, 02 Feb 2017)

Log Message

Correct memory leak in MediaConstraints
https://bugs.webkit.org/show_bug.cgi?id=167744
<rdar://problem/30331444>

Reviewed by Anders Carlsson.

ConstraintHolder returns a reference to an object created by operator new. When the
returned value is assigned or stored in Vector or other containers we leak memory.
Instead, this value should just be returned as a regular object so that the return
value optimization can make sure memory is properly (and efficiently) used.

* platform/mediastream/MediaConstraints.h:
(WebCore::FlattenedConstraint::ConstraintHolder::create): Return by value.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (211578 => 211579)


--- trunk/Source/WebCore/ChangeLog	2017-02-02 19:20:20 UTC (rev 211578)
+++ trunk/Source/WebCore/ChangeLog	2017-02-02 19:33:09 UTC (rev 211579)
@@ -1,3 +1,19 @@
+2017-02-02  Brent Fulgham  <bfulg...@apple.com>
+
+        Correct memory leak in MediaConstraints
+        https://bugs.webkit.org/show_bug.cgi?id=167744
+        <rdar://problem/30331444>
+
+        Reviewed by Anders Carlsson.
+
+        ConstraintHolder returns a reference to an object created by operator new. When the
+        returned value is assigned or stored in Vector or other containers we leak memory.
+        Instead, this value should just be returned as a regular object so that the return
+        value optimization can make sure memory is properly (and efficiently) used.
+
+        * platform/mediastream/MediaConstraints.h:
+        (WebCore::FlattenedConstraint::ConstraintHolder::create): Return by value.
+
 2017-02-02  Andreas Kling  <akl...@apple.com>
 
         [Mac] In-process memory pressure monitor for WebContent processes AKA websam

Modified: trunk/Source/WebCore/platform/mediastream/MediaConstraints.h (211578 => 211579)


--- trunk/Source/WebCore/platform/mediastream/MediaConstraints.h	2017-02-02 19:20:20 UTC (rev 211578)
+++ trunk/Source/WebCore/platform/mediastream/MediaConstraints.h	2017-02-02 19:33:09 UTC (rev 211579)
@@ -713,7 +713,7 @@
 private:
     class ConstraintHolder {
     public:
-        static ConstraintHolder& create(const MediaConstraint& value) { return *new ConstraintHolder(value); }
+        static ConstraintHolder create(const MediaConstraint& value) { return ConstraintHolder(value); }
 
         ~ConstraintHolder()
         {
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to