Underflow protection in hb_vector_t
This commit is contained in:
parent
f83e992c8b
commit
31c4236d96
|
@ -685,8 +685,9 @@ struct hb_vector_t
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool resize (unsigned int size)
|
inline bool resize (int size_)
|
||||||
{
|
{
|
||||||
|
unsigned int size = size_ < 0 ? 0u : (unsigned int) size_;
|
||||||
if (!alloc (size))
|
if (!alloc (size))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
@ -696,6 +697,7 @@ struct hb_vector_t
|
||||||
|
|
||||||
inline void pop (void)
|
inline void pop (void)
|
||||||
{
|
{
|
||||||
|
if (!len) return;
|
||||||
len--;
|
len--;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -709,10 +711,11 @@ struct hb_vector_t
|
||||||
len--;
|
len--;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void shrink (unsigned int l)
|
inline void shrink (int size_)
|
||||||
{
|
{
|
||||||
if (l < len)
|
unsigned int size = size_ < 0 ? 0u : (unsigned int) size_;
|
||||||
len = l;
|
if (size < len)
|
||||||
|
len = size;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
|
|
Loading…
Reference in New Issue