mirror of
https://github.com/storytold/harfbuzz.git
synced 2026-11-20 22:41:10 +01:00
[internal] Replace remaining vector resize(0) with clear()
Two callers were still using vector.resize(0) to drop accumulated
data: graph/serialize.hh's overflow tracking and hb_bit_set_t's
clear() (via its own internal resize()). resize(0) on a vector
in error state short-circuits without zeroing length, leaving
stale entries that downstream code then walks as if valid.
Fix both:
- serialize.hh: call overflows->clear() instead.
- hb-bit-set.hh: reimplement clear() to zero length/population
unconditionally by calling pages.clear() / page_map.clear()
directly, bypassing the internal resize() that bails when
`successful` is false.
Mirrors the March clear() fix in hb-vector.hh (commit d134f88824).
Assisted-by: Claude <noreply@anthropic.com>
This commit is contained in:
1 parent
fe04146acb
commit
2adb01a47c
2 files changed
+6
-4
No files matched your search
@@ -108,7 +108,7 @@ inline bool
|
||||
will_overflow (graph_t& graph,
|
||||
hb_vector_t<overflow_record_t>* overflows = nullptr)
|
||||
{
|
||||
if (overflows) overflows->resize (0);
|
||||
if (overflows) overflows->clear ();
|
||||
graph.update_positions ();
|
||||
|
||||
hb_hashmap_t<overflow_record_t*, bool> record_set;
|
||||
|
||||
+5
-3
@@ -117,9 +117,11 @@ struct hb_bit_set_t
|
||||
|
||||
void clear ()
|
||||
{
|
||||
resize (0);
|
||||
if (likely (successful))
|
||||
population = 0;
|
||||
/* Always zero length and population, even when in error state,
|
||||
* so a stale set can't leak pages into a subsequent reuse. */
|
||||
pages.clear ();
|
||||
page_map.clear ();
|
||||
population = 0;
|
||||
}
|
||||
bool is_empty () const
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user