mirror of
https://github.com/harfbuzz/harfbuzz.git
synced 2025-04-14 17:13:40 +00:00
[vector] Keep allocated size when in error
This commit is contained in:
parent
9df07c3c30
commit
dbdeb2649d
1 changed files with 4 additions and 8 deletions
|
@ -86,7 +86,7 @@ struct hb_vector_t
|
|||
~hb_vector_t () { fini (); }
|
||||
|
||||
public:
|
||||
int allocated = 0; /* == -1 means allocation failed. */
|
||||
int allocated = 0; /* < 0 means allocation failed. */
|
||||
unsigned int length = 0;
|
||||
public:
|
||||
Type *arrayZ = nullptr;
|
||||
|
@ -116,11 +116,7 @@ struct hb_vector_t
|
|||
void reset ()
|
||||
{
|
||||
if (unlikely (in_error ()))
|
||||
/* Big Hack! We don't know the true allocated size before
|
||||
* an allocation failure happened. But we know it was at
|
||||
* least as big as length. Restore it to that and continue
|
||||
* as if error did not happen. */
|
||||
allocated = length;
|
||||
allocated = -allocated;
|
||||
resize (0);
|
||||
}
|
||||
|
||||
|
@ -396,7 +392,7 @@ struct hb_vector_t
|
|||
|
||||
if (unlikely (overflows))
|
||||
{
|
||||
allocated = -1;
|
||||
allocated = -allocated;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -407,7 +403,7 @@ struct hb_vector_t
|
|||
if (new_allocated <= (unsigned) allocated)
|
||||
return true; // shrinking failed; it's okay; happens in our fuzzer
|
||||
|
||||
allocated = -1;
|
||||
allocated = -allocated;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue