From 99d6536c326a4df3bfb964f421edc2a005deb851 Mon Sep 17 00:00:00 2001 From: Po Lu Date: Thu, 17 Feb 2022 02:32:55 +0000 Subject: [PATCH] Fix SIGFPE on some fonts when calculating their average width on Haiku * src/haiku_font_support.cc (estimate_font_ascii): Avoid divison by zero. --- src/haiku_font_support.cc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/haiku_font_support.cc b/src/haiku_font_support.cc index 3930cd965f6..549c54d8649 100644 --- a/src/haiku_font_support.cc +++ b/src/haiku_font_support.cc @@ -68,7 +68,11 @@ estimate_font_ascii (BFont *font, int *max_width, *min_width = min; *max_width = max; - *avg_width = total / count; + + if (count) + *avg_width = total / count; + else + *avg_width = 0; } void -- 2.39.5