GNU bug report logs - #11541
24.0.97; Crash when visiting file on OS X 10.7.3

Previous Next

Packages: ns, emacs;

Reported by: Florian Ebeling <florian.ebeling <at> gmail.com>

Date: Tue, 22 May 2012 16:20:02 UTC

Severity: important

Merged with 11684, 11792, 11801

Found in versions 24.0.97, 24.1.50, 24.1

Done: Jan Djärv <jan.h.d <at> swipnet.se>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Thomas Kappler <tkappler <at> gmail.com>
To: 11541 <at> debbugs.gnu.org
Subject: bug#11541: Possible fix
Date: Tue, 6 Nov 2012 12:01:00 +0100
[Message part 1 (text/plain, inline)]
I investigated this a bit further and have a patch that fixes the
right-arrow test file for me, I can open it and the arrow displays without
problems.

Note that this is my very first foray into the Emacs source as well as into
Objective-C.

The problem is that ns_findfonts is being passed an empty font_spec. (Why,
I have no idea.) This crashes "[fdesc
matchingFontDescriptorsWithMandatoryKeys: fkeys]". The fix is to check for
this case and, if there are no keys in the font_spec, simply initialize
matchingDescs to an empty array.

Cheers,
Thomas


$ bzr diff

=== modified file 'src/nsfont.m'
--- src/nsfont.m    2012-10-21 18:48:11 +0000
+++ src/nsfont.m    2012-11-06 10:55:25 +0000
@@ -43,7 +43,7 @@
 #import <AppKit/NSFontDescriptor.h>
 #endif

-#define NSFONT_TRACE 0
+#define NSFONT_TRACE 1

 extern Lisp_Object Qns;
 extern Lisp_Object Qnormal, Qbold, Qitalic, Qcondensed, Qexpanded;
@@ -556,10 +556,17 @@

     fdesc = ns_spec_to_descriptor (font_spec);
     fkeys = [NSMutableSet setWithArray: [[fdesc fontAttributes] allKeys]];
+    if (NSFONT_TRACE)
+        NSLog(@"Got %d fkeys: %@ ", [fkeys count], fkeys);
+
     if (isMatch)
     [fkeys removeObject: NSFontFamilyAttribute];

-    matchingDescs = [fdesc matchingFontDescriptorsWithMandatoryKeys:
fkeys];
+    if ([fkeys count] > 0) {
+    matchingDescs = [fdesc matchingFontDescriptorsWithMandatoryKeys:
fkeys];
+    } else {
+    matchingDescs = [NSMutableArray array];
+    }
     if (NSFONT_TRACE)
     NSLog(@"Got desc %@ and found %d matching fonts from it: ", fdesc,
           [matchingDescs count]);
[Message part 2 (text/html, inline)]

This bug report was last modified 12 years and 256 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.