]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix SIGFPE on some fonts when calculating their average width on Haiku
authorPo Lu <luangruo@yahoo.com>
Thu, 17 Feb 2022 02:32:55 +0000 (02:32 +0000)
committerPo Lu <luangruo@yahoo.com>
Thu, 17 Feb 2022 02:32:55 +0000 (02:32 +0000)
* src/haiku_font_support.cc (estimate_font_ascii): Avoid divison
by zero.

src/haiku_font_support.cc

index 3930cd965f621050e841c56857bd1dff61636122..549c54d86494cf5c7016912cc84f4f2e927506ea 100644 (file)
@@ -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