APPROVE 21.5
That said, I don't like this because of the memory allocation implied,
and because I suspect my own patch was too intrusive. The crashes
seem to be only from the PRINT_XFT_PATTERN code (at least for me). I
don't understand why there are crashes there but not elsewhere yet.
The patch is OK for now, and I'll open an issue for it later, but I
wanted to raise the question here now so that others who have looked
at the code will be aware of it.
Steve
Michael Sperber writes:
This patch ...
2014-10-18 Stephen J. Turnbull <stephen(a)xemacs.org>
* fontcolor-xlike-inc.c (xft_find_charset_font):
* fontcolor-x.c (x_font_instance_truename):
* font-mgr.c (Ffc_name_unparse):
Protect Ffc_name_unparse from FcNameUnparse crash on charset property.
... caused some breakage for me. In particular, the test whether a
particular font implements a charset would always fail. The reason is
that fc patterns passed as arguments are modified in place. This patch
fixes that.
I'll push on Monday if nobody objects.
2014-10-25 Michael Sperber <mike(a)xemacs.org>
* fontcolor-x.c (x_font_instance_truename):
* font-mgr.c (Ffc_name_unparse):
* font-mgr.h (PRINT_XFT_PATTERN): Don't modify
fontconfig pattern passed in in place.
--
Regards,
Mike
diff --git a/src/font-mgr.c b/src/font-mgr.c
--- a/src/font-mgr.c
+++ b/src/font-mgr.c
@@ -266,9 +266,12 @@
CHECK_FC_PATTERN (pattern);
/* #### Could use multiple values here to extract and return charset? */
- FcPatternDel (XFC_PATTERN_PTR (pattern), FC_CHARSET);
-
- name = FcNameUnparse (XFC_PATTERN_PTR (pattern));
+ {
+ FcPattern* temp = FcPatternDuplicate (XFC_PATTERN_PTR (pattern));
+ FcPatternDel (temp, FC_CHARSET);
+ name = FcNameUnparse (XFC_PATTERN_PTR (pattern));
+ FcPatternDestroy (temp);
+ }
result = build_fcapi_string (name);
xfree (name);
return result;
diff --git a/src/font-mgr.h b/src/font-mgr.h
--- a/src/font-mgr.h
+++ b/src/font-mgr.h
@@ -145,8 +145,10 @@
do { \
DECLARE_EISTRING (eistrpxft_name); \
Extbyte *name; \
- FcPatternDel(pattern, FC_CHARSET); \
- name = (Extbyte *) FcNameUnparse (pattern); \
+ FcPattern* temp = FcPatternDuplicate (pattern); \
+ FcPatternDel (temp, FC_CHARSET); \
+ name = (Extbyte *) FcNameUnparse (temp); \
+ FcPatternDestroy (temp); \
eicpy_ext(eistrpxft_name, \
name ? name : "FONT WITH NULL NAME", \
Qfc_font_name_encoding); \
diff --git a/src/fontcolor-x.c b/src/fontcolor-x.c
--- a/src/fontcolor-x.c
+++ b/src/fontcolor-x.c
@@ -763,8 +763,12 @@
"Xft font present but lacks pattern",
wrap_font_instance(f), Qfont, errb);
}
- FcPatternDel (pattern, FC_CHARSET); /* FcNameUnparse may choke */
- res = FcNameUnparse (pattern);
+ {
+ FcPattern* temp = FcPatternDuplicate (pattern);
+ FcPatternDel (temp, FC_CHARSET); /* FcNameUnparse may choke */
+ res = FcNameUnparse (temp);
+ FcPatternDestroy (temp);
+ }
if (res)
{
FONT_INSTANCE_TRUENAME (f) =
_______________________________________________
XEmacs-Patches mailing list
XEmacs-Patches(a)xemacs.org
http://lists.xemacs.org/mailman/listinfo/xemacs-patches
_______________________________________________
XEmacs-Patches mailing list
XEmacs-Patches(a)xemacs.org