mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-25 13:51:41 +00:00
Bug 1249389 - part 3 - assert the size of nsZipItemPtr's storage type; r=erahm
The only uses of this class use a template argument with a size of |char| (uint8_t and char), and the class isn't designed to accomodate template arguments of larger size (e.g. the implementation of Forget() neglects to divide by sizeof(T) for allocating a return buffer). Let's enforce this with a static_assert. This change makes the class safer to use and also makes future changes simpler to reason about.
This commit is contained in:
parent
f49b2c8d86
commit
460db498a3
@ -350,6 +350,10 @@ protected:
|
||||
template <class T>
|
||||
class nsZipItemPtr final : public nsZipItemPtr_base
|
||||
{
|
||||
static_assert(sizeof(T) == sizeof(char),
|
||||
"This class cannot be used with larger T without re-examining"
|
||||
" a number of assumptions.");
|
||||
|
||||
public:
|
||||
nsZipItemPtr(nsZipArchive *aZip, const char *aEntryName, bool doCRC = false) : nsZipItemPtr_base(aZip, aEntryName, doCRC) { }
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user