[libbluray-devel] BDFontMetrics: fix crash in stringWidth()

hpi1 git at videolan.org
Thu Apr 30 11:50:18 CEST 2015


libbluray | branch: master | hpi1 <hpi1 at anonymous.org> | Tue Apr  7 09:47:46 2015 +0300| [5879ed9627ce068355a4f2460b2dd0b1f398113f] | committer: hpi1

BDFontMetrics: fix crash in stringWidth()

Calling this function from multiple threads caused crash in freetype.

> http://git.videolan.org/gitweb.cgi/libbluray.git/?a=commit;h=5879ed9627ce068355a4f2460b2dd0b1f398113f
---

 src/libbluray/bdj/java/java/awt/BDFontMetrics.java |    7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/libbluray/bdj/java/java/awt/BDFontMetrics.java b/src/libbluray/bdj/java/java/awt/BDFontMetrics.java
index 217c0a2..d2a91dc 100644
--- a/src/libbluray/bdj/java/java/awt/BDFontMetrics.java
+++ b/src/libbluray/bdj/java/java/awt/BDFontMetrics.java
@@ -282,7 +282,12 @@ public class BDFontMetrics extends sun.font.FontDesignMetrics {
      * Return the width of the specified string in this Font.
      */
     public synchronized int stringWidth(String string) {
-        return stringWidthN(ftFace, string);
+        /* Allow only one call at time.
+         * (calling this function from multiple threads caused crashes in freetype)
+         */
+        synchronized (BDFontMetrics.class) {
+            return stringWidthN(ftFace, string);
+        }
     }
 
     /**



More information about the libbluray-devel mailing list