Make sure we make progress in OOM situations
This commit is contained in:
parent
5a7eb5d4d8
commit
68b507a3c3
|
@ -175,15 +175,12 @@ struct hb_buffer_t {
|
|||
{
|
||||
if (unlikely (out_info != info || out_len != idx)) {
|
||||
if (unlikely (!make_room_for (1, 1)))
|
||||
{
|
||||
idx++; // So we don't hang indefinitely...
|
||||
return;
|
||||
}
|
||||
goto done;
|
||||
out_info[out_len] = info[idx];
|
||||
}
|
||||
out_len++;
|
||||
}
|
||||
|
||||
done:
|
||||
idx++;
|
||||
}
|
||||
|
||||
|
|
|
@ -324,7 +324,9 @@ hb_buffer_t::replace_glyphs (unsigned int num_in,
|
|||
unsigned int num_out,
|
||||
const uint32_t *glyph_data)
|
||||
{
|
||||
if (unlikely (!make_room_for (num_in, num_out))) return;
|
||||
if (unlikely (!make_room_for (num_in, num_out)))
|
||||
goto done;
|
||||
{
|
||||
|
||||
merge_clusters (idx, idx + num_in);
|
||||
|
||||
|
@ -337,39 +339,50 @@ hb_buffer_t::replace_glyphs (unsigned int num_in,
|
|||
pinfo++;
|
||||
}
|
||||
|
||||
idx += num_in;
|
||||
out_len += num_out;
|
||||
}
|
||||
done:
|
||||
idx += num_in;
|
||||
}
|
||||
|
||||
void
|
||||
hb_buffer_t::output_glyph (hb_codepoint_t glyph_index)
|
||||
{
|
||||
if (unlikely (!make_room_for (0, 1))) return;
|
||||
if (unlikely (!make_room_for (0, 1)))
|
||||
goto done;
|
||||
|
||||
out_info[out_len] = info[idx];
|
||||
out_info[out_len].codepoint = glyph_index;
|
||||
|
||||
out_len++;
|
||||
done:
|
||||
;
|
||||
}
|
||||
|
||||
void
|
||||
hb_buffer_t::output_info (const hb_glyph_info_t &glyph_info)
|
||||
{
|
||||
if (unlikely (!make_room_for (0, 1))) return;
|
||||
if (unlikely (!make_room_for (0, 1)))
|
||||
goto done;
|
||||
|
||||
out_info[out_len] = glyph_info;
|
||||
|
||||
out_len++;
|
||||
done:
|
||||
;
|
||||
}
|
||||
|
||||
void
|
||||
hb_buffer_t::copy_glyph (void)
|
||||
{
|
||||
if (unlikely (!make_room_for (0, 1))) return;
|
||||
if (unlikely (!make_room_for (0, 1)))
|
||||
goto done;
|
||||
|
||||
out_info[out_len] = info[idx];
|
||||
|
||||
out_len++;
|
||||
done:
|
||||
;
|
||||
}
|
||||
|
||||
bool
|
||||
|
@ -387,7 +400,7 @@ hb_buffer_t::move_to (unsigned int i)
|
|||
if (out_len < i)
|
||||
{
|
||||
unsigned int count = i - out_len;
|
||||
if (unlikely (!make_room_for (count, count))) return false;
|
||||
if (unlikely (!make_room_for (count, count))) return false; // XXX verify bailout
|
||||
|
||||
memmove (out_info + out_len, info + idx, count * sizeof (out_info[0]));
|
||||
idx += count;
|
||||
|
@ -414,13 +427,15 @@ void
|
|||
hb_buffer_t::replace_glyph (hb_codepoint_t glyph_index)
|
||||
{
|
||||
if (unlikely (out_info != info || out_len != idx)) {
|
||||
if (unlikely (!make_room_for (1, 1))) return;
|
||||
if (unlikely (!make_room_for (1, 1)))
|
||||
goto out;
|
||||
out_info[out_len] = info[idx];
|
||||
}
|
||||
out_info[out_len].codepoint = glyph_index;
|
||||
|
||||
idx++;
|
||||
out_len++;
|
||||
out:
|
||||
idx++;
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue