Bug 702799 - Don't modify a RefPtr when using the implicit conversion to TemporaryRef. r=cjones
authorJoe Drew <joe@drew.ca>
Mon, 21 Nov 2011 16:42:07 -0500
changeset 82236 3b3c9e09abe39372b3d8cb488f1c7e827db9299b
parent 82235 f6be9ad957b1963884b9dc599ac72e34bf7c1c92
child 82237 38e4456727805e36a044ad07bca9000437fb1fcd
push idunknown
push userunknown
push dateunknown
reviewerscjones
bugs702799
milestone11.0a1
Bug 702799 - Don't modify a RefPtr when using the implicit conversion to TemporaryRef. r=cjones
mfbt/RefPtr.h
--- a/mfbt/RefPtr.h
+++ b/mfbt/RefPtr.h
@@ -169,17 +169,17 @@ public:
         return TemporaryRef<T>(tmp, dontRef());
     }
 
     T* get() const { return ptr; }
     operator T*() const { return ptr; }
     T* operator->() const { return ptr; }
     T& operator*() const { return *ptr; }
     template<typename U>
-    operator TemporaryRef<U>() { return forget(); }
+    operator TemporaryRef<U>() { return TemporaryRef<U>(ptr); }
 
 private:
     void assign(T* t) {
         unref(ptr);
         ptr = t;
     }
 
     T* ptr;