mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07: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
42baa283e9
commit
22fa651d41
@ -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