I and Benoit Jacob discovered a bug in WeakPtr (bug 924658) which makes its
usage unsafe by default.  The issue is that WeakPtr provides convenience
methods such as operator->, which mean that the consumer can directly
dereference it without the required null checking first.  This means that
you can have code like the below:

WeakPtr<Class> foo = realObject->asWeakPtr();
// ...
foo->Method();

That will happily compile and will crash at runtime if the object behind
the weak pointer is dead.  The correct way of writing such code is:

Class* object = foo.get();
if (object) {
  object->Method();
}

I don't know enough about all of the places which use WeakPtr myself to fix
them all, but if you have code using this in your module, please spend some
time auditing the code, and fix it.  Please file individual bugs for your
components blocking bug 924658.

Thanks!
--
Ehsan
<http://ehsanakhgari.org/>
_______________________________________________
dev-platform mailing list
dev-platform@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-platform

Reply via email to