RESOLVED FIXED Bug 32363
[Chromium] Disallow assignment of WebVector<T> to WebVector<T>
https://bugs.webkit.org/show_bug.cgi?id=32363
Summary [Chromium] Disallow assignment of WebVector<T> to WebVector<T>
Yury Semikhatsky
Reported 2009-12-10 00:28:52 PST
As comment in the top part of WebVector.h says WebVector::swap should be used in such cases. If you write by mistake something as follows: WebVector<WebString> a(3); WebVector<WebString> b; b = a; operator= automatically generated by compiler will be invoked as it takes precedence over template version template <typename C> WebVector<T>& operator=(const C& other) The default assignment operator will lead to a.m_ptr == b.m_ptr and to destructor being called twice for the container elements. So either operator= should have valid implementation or be disallowed explicitly.
Attachments
patch (947 bytes, patch)
2009-12-10 00:33 PST, Yury Semikhatsky
fishd: review-
patch addressing reviewers comments (1.03 KB, patch)
2009-12-14 08:06 PST, Yury Semikhatsky
levin: review+
Yury Semikhatsky
Comment 1 2009-12-10 00:33:03 PST
Created attachment 44598 [details] patch Not sure where I could place unit test for this.
WebKit Review Bot
Comment 2 2009-12-10 00:36:28 PST
style-queue ran check-webkit-style on attachment 44598 [details] without any errors.
Eric Seidel (no email)
Comment 3 2009-12-10 00:57:29 PST
Comment on attachment 44598 [details] patch We have wtf/Noncopyable for this sort of thing. But that can't be used here, so this is probably fine.
Darin Fisher (:fishd, Google)
Comment 4 2009-12-11 10:12:16 PST
Comment on attachment 44598 [details] patch Actually, the intent was to allow copying just as you can copy a std::vector or a WTF::Vector. I think we should implement this assignment operator.
Yury Semikhatsky
Comment 5 2009-12-14 08:06:39 PST
Created attachment 44797 [details] patch addressing reviewers comments
WebKit Review Bot
Comment 6 2009-12-14 08:10:44 PST
style-queue ran check-webkit-style on attachment 44797 [details] without any errors.
Yury Semikhatsky
Comment 7 2009-12-14 08:14:21 PST
(In reply to comment #4) > (From update of attachment 44598 [details]) > Actually, the intent was to allow copying just as you can copy a std::vector or > a WTF::Vector. I think we should implement this assignment operator. Done. I've added "non-template" operator=.
Yury Semikhatsky
Comment 8 2009-12-17 09:07:00 PST
Committing to http://svn.webkit.org/repository/webkit/trunk ... M WebKit/chromium/ChangeLog M WebKit/chromium/public/WebVector.h Committed r52255
Note You need to log in before you can comment on or make changes to this bug.