aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPaul Eggert2018-06-07 18:53:26 -0700
committerPaul Eggert2018-06-07 19:11:49 -0700
commit4d176b742774670c5c265a06f742e63a43f5f7ab (patch)
tree37aa1e3ed6537f8430e9c54a126423d27bc7e360 /src
parentb76389f22070bb61811eeea41635640d31115fd9 (diff)
downloademacs-4d176b742774670c5c265a06f742e63a43f5f7ab.tar.gz
emacs-4d176b742774670c5c265a06f742e63a43f5f7ab.zip
Fix ftfont_open2 failure cleanup
* src/ftfont.c (ftfont_open2): Don’t increment counter if failing. Avoid use-after-free once the increment bug is fixed.
Diffstat (limited to 'src')
-rw-r--r--src/ftfont.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/ftfont.c b/src/ftfont.c
index 9a8777ef078..a53467000f3 100644
--- a/src/ftfont.c
+++ b/src/ftfont.c
@@ -1131,16 +1131,19 @@ ftfont_open2 (struct frame *f,
1131 return Qnil; 1131 return Qnil;
1132 } 1132 }
1133 } 1133 }
1134 set_save_integer (val, 1, XSAVE_INTEGER (val, 1) + 1);
1135 size = XINT (AREF (entity, FONT_SIZE_INDEX)); 1134 size = XINT (AREF (entity, FONT_SIZE_INDEX));
1136 if (size == 0) 1135 if (size == 0)
1137 size = pixel_size; 1136 size = pixel_size;
1138 if (FT_Set_Pixel_Sizes (ft_face, size, size) != 0) 1137 if (FT_Set_Pixel_Sizes (ft_face, size, size) != 0)
1139 { 1138 {
1140 if (XSAVE_INTEGER (val, 1) == 0) 1139 if (XSAVE_INTEGER (val, 1) == 0)
1141 FT_Done_Face (ft_face); 1140 {
1141 FT_Done_Face (ft_face);
1142 cache_data->ft_face = NULL;
1143 }
1142 return Qnil; 1144 return Qnil;
1143 } 1145 }
1146 set_save_integer (val, 1, XSAVE_INTEGER (val, 1) + 1);
1144 1147
1145 ASET (font_object, FONT_FILE_INDEX, filename); 1148 ASET (font_object, FONT_FILE_INDEX, filename);
1146 font = XFONT_OBJECT (font_object); 1149 font = XFONT_OBJECT (font_object);