For anyone who's not reading planet (or hasn't read it in the last fifteen 
minutes ;-) ), I recently landed a new mfbt header that exposes slightly safer 
versions of memset(.., 0, ...), memcpy, and memcmp for use on C++ types, 
particularly ones where sizeof(T) > 1.

http://mxr.mozilla.org/mozilla-central/source/mfbt/PodOperations.h

The problem is that it's easy to forget to multiply the appropriate parameter 
in these methods by sizeof(T) when necessary.  Doing so can lead to various 
issues like incompletely-initialized values, issues causing security 
vulnerabilities in the past.  PodOperations.h throws some C++ template methods 
at the problem, to eliminate the need to remember to add sizeof(T).  This 
stuff's been used by the JS engine for awhile -- I just moved it out of there 
and to a centralized place for everyone to use.

More details here if you want them:

http://whereswalden.com/2013/04/26/mozillapodoperations-h-functions-for-zeroing-assigning-to-copying-and-comparing-plain-old-data-objects/

Jeff
_______________________________________________
dev-platform mailing list
dev-platform@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-platform

Reply via email to