Commit eaa28a24 authored by Volker Krause's avatar Volker Krause
Browse files

Check if content type fits into content data before casting to it

parent a65431a1
......@@ -57,8 +57,11 @@ public:
/** Convenience method to access typed content. */
template <typename T>
inline const T* contentAt(int offset) const
inline const T* contentAt(int offset = 0) const
{
if (offset < 0 || (int)sizeof(T) > contentSize() - offset) {
return nullptr;
}
return reinterpret_cast<const T*>(contentData() + offset);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment