Prevent undefined behavior when serializing empty vector (#122)
Since m_get_const_function calls `std::vector<T>::operator[]`, accessing the zeroth element causes undefined behavior. Instead, return a null pointer to make the function behave sanely when vector is empty. Fix #120
This commit is contained in:
parent
025762ac4f
commit
3ea93f27aa
1 changed files with 2 additions and 0 deletions
|
@ -245,6 +245,8 @@ public:
|
|||
}
|
||||
const void * sequence_contents(const void * ptr_to_sequence) const override
|
||||
{
|
||||
if(sequence_size(ptr_to_sequence) == 0)
|
||||
return nullptr;
|
||||
return m_get_const_function(ptr_to_sequence, 0);
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue