From 85658394809fe0593ab5dfb30fd96118765c7dc5 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Wed, 4 Nov 2015 14:46:52 -0800 Subject: [PATCH] Protect against possible invalid-memory access after OOM --- src/hb-buffer-private.hh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/hb-buffer-private.hh b/src/hb-buffer-private.hh index c25540891..521214de9 100644 --- a/src/hb-buffer-private.hh +++ b/src/hb-buffer-private.hh @@ -76,8 +76,8 @@ struct hb_buffer_t { inline hb_glyph_position_t &cur_pos (unsigned int i = 0) { return pos[idx + i]; } inline hb_glyph_position_t cur_pos (unsigned int i = 0) const { return pos[idx + i]; } - inline hb_glyph_info_t &prev (void) { return out_info[out_len - 1]; } - inline hb_glyph_info_t prev (void) const { return out_info[out_len - 1]; } + inline hb_glyph_info_t &prev (void) { return out_info[out_len ? out_len - 1 : 0]; } + inline hb_glyph_info_t prev (void) const { return out_info[out_len ? out_len - 1 : 0]; } inline bool has_separate_output (void) const { return info != out_info; }