- Do not make missing font sets a fatal error (#658526)

This commit is contained in:
Hans de Goede 2010-12-01 14:48:43 +01:00
parent 62fb29d863
commit 0d68681bd6
2 changed files with 31 additions and 224 deletions

View File

@ -1,3 +1,28 @@
This is commit 762bcb8c50fd0256a545ad6ed2304403daca8081 from
Markus Steinborn <gnugv_maintainer@yahoo.de> Xaw3d git repo, with
the making a missing fontset abort changes removed, while keeping the
checks for missing fonts as those can lead to NULL ptr dereferences.
The checks for missing font sets is removed, because when the locale
is set to a UTF-8 locale (default now a days on most Linux distributions),
libXt will usually print:
Warning: Missing charsets in String to FontSet conversion
Warning: Unable to load any usable fontset
When resolving any fontset string, and return a NULL fontset.
For more details on this issue see:
http://tracker.xemacs.org/XEmacs/its/issue650
This however is not a fatal error (it means the default font set will be
used, and that some characters of the entire unicode range may not render
properly).
The changes in the original commit made this a fatal error causing many
programs, which worked fine before, to abort.
Below is the header of the orignal patch for reference:
From 762bcb8c50fd0256a545ad6ed2304403daca8081 Mon Sep 17 00:00:00 2001
From: Markus Steinborn <gnugv_maintainer@yahoo.de>
Date: Sat, 24 Apr 2010 16:54:35 +0200
@ -40,170 +65,19 @@ index 6e04860..9f22d78 100644
if (cbw->command.shape_style != XawShapeRectangle
&& !XShapeQueryExtension(XtDisplay(new), &shape_event_base,
&shape_error_base))
diff --git a/xc/lib/Xaw3d/Label.c b/xc/lib/Xaw3d/Label.c
index c4e1ff9..7e964f8 100644
--- a/xc/lib/Xaw3d/Label.c
+++ b/xc/lib/Xaw3d/Label.c
@@ -278,7 +278,10 @@ static void SetTextWidthAndHeight(lw)
#ifdef XAW_INTERNATIONALIZATION
if ( lw->simple.international == True ) {
XFontSet fset = lw->label.fontset;
- XFontSetExtents *ext = XExtentsOfFontSet(fset);
+ XFontSetExtents *ext;
+
+ if (!lw->label.fontset || !(ext = XExtentsOfFontSet(fset)))
+ XtError("Aborting: no fontset found\n");
lw->label.label_height = ext->max_ink_extent.height;
if (lw->label.label == NULL) {
@@ -468,6 +471,12 @@ static void Initialize(request, new, args, num_args)
lw->threeD.shadow_width = 0;
#endif
+ if (!lw->label.font) XtError("Aborting: no font found\n");
+#ifdef XAW_INTERNATIONALIZATION
+ if (lw->simple.international && !lw->label.fontset)
+ XtError("Aborting: no fontset found\n");
+#endif
+
if (lw->label.label == NULL)
lw->label.label = XtNewString(lw->core.name);
else
diff --git a/xc/lib/Xaw3d/List.c b/xc/lib/Xaw3d/List.c
index 99faf31..e7d7d57 100644
--- a/xc/lib/Xaw3d/List.c
+++ b/xc/lib/Xaw3d/List.c
@@ -366,6 +366,12 @@ Cardinal *num_args;
@@ -366,6 +366,8 @@ Cardinal *num_args;
{
ListWidget lw = (ListWidget) new;
+ if (!lw->list.font) XtError("Aborting: no font found\n");
+#ifdef XAW_INTERNATIONALIZATION
+ if (lw->simple.international && !lw->list.fontset)
+ XtError("Aborting: no fontset found\n");
+#endif
+
/*
* Initialize all private resources.
*/
@@ -590,7 +596,9 @@ int item;
int x, y, str_y;
ListWidget lw = (ListWidget) w;
#ifdef XAW_INTERNATIONALIZATION
- XFontSetExtents *ext = XExtentsOfFontSet(lw->list.fontset);
+ XFontSetExtents *ext;
+ if (!lw->list.fontset || !(ext = XExtentsOfFontSet(lw->list.fontset)))
+ XtError("Aborting: no fontset found\n");
#endif
if (!XtIsRealized(w)) return; /* Just in case... */
@@ -969,7 +977,9 @@ Cardinal *num_args;
ListWidget nl = (ListWidget) new;
Boolean redraw = FALSE;
#ifdef XAW_INTERNATIONALIZATION
- XFontSetExtents *ext = XExtentsOfFontSet(nl->list.fontset);
+ XFontSetExtents *ext;
+ if (!nl->list.fontset || !(ext = XExtentsOfFontSet(nl->list.fontset)))
+ XtError("Aborting: no fontset found\n");
#endif
/* If the request height/width is different, lock it. Unless its 0. If */
diff --git a/xc/lib/Xaw3d/MultiSink.c b/xc/lib/Xaw3d/MultiSink.c
index d8aac3f..0c4d7d0 100644
--- a/xc/lib/Xaw3d/MultiSink.c
+++ b/xc/lib/Xaw3d/MultiSink.c
@@ -254,7 +254,9 @@ PaintText(w, gc, x, y, buf, len)
XFontSet fontset = sink->multi_sink.fontset;
Position max_x;
Dimension width = XwcTextEscapement(fontset, buf, len);
- XFontSetExtents *ext = XExtentsOfFontSet(fontset);
+ XFontSetExtents *ext;
+ if (!fontset || !(ext = XExtentsOfFontSet(fontset)))
+ XtError("Aborting: no fontset found\n");
max_x = (Position) ctx->core.width;
if ( ((int) width) <= -x) /* Don't draw if we can't see it. */
@@ -291,7 +293,9 @@ DisplayText(w, x, y, pos1, pos2, highlight)
MultiSinkObject sink = (MultiSinkObject) w;
Widget source = XawTextGetSource(XtParent(w));
wchar_t buf[BUFSIZ];
- XFontSetExtents *ext = XExtentsOfFontSet(sink->multi_sink.fontset);
+ XFontSetExtents *ext;
+ if (!sink->multi_sink.fontset || !(ext = XExtentsOfFontSet(sink->multi_sink.fontset)))
+ XtError("Aborting: no fontset found\n");
int j, k;
XawTextBlock blk;
@@ -420,8 +424,10 @@ FindDistance (w, fromPos, fromx, toPos, resWidth, resPos, resHeight)
XawTextPosition index, lastPos;
wchar_t c;
- XFontSetExtents *ext = XExtentsOfFontSet(sink->multi_sink.fontset);
XawTextBlock blk;
+ XFontSetExtents *ext;
+ if (!sink->multi_sink.fontset || !(ext = XExtentsOfFontSet(sink->multi_sink.fontset)))
+ XtError("Aborting: no fontset found\n");
/* we may not need this */
lastPos = GETLASTPOS;
@@ -461,8 +467,10 @@ FindPosition(w, fromPos, fromx, width, stopAtWordBreak, resPos, resWidth, resHei
int lastWidth = 0, whiteSpaceWidth = 0;
Boolean whiteSpaceSeen;
wchar_t c;
- XFontSetExtents *ext = XExtentsOfFontSet(sink->multi_sink.fontset);
XawTextBlock blk;
+ XFontSetExtents *ext;
+ if (!sink->multi_sink.fontset || !(ext = XExtentsOfFontSet(sink->multi_sink.fontset)))
+ XtError("Aborting: no fontset found\n");
lastPos = GETLASTPOS;
@@ -566,7 +574,11 @@ Initialize(request, new, args, num_args)
MultiSinkObject sink = (MultiSinkObject) new;
GetGC(sink);
-
+
+#ifdef XAW_INTERNATIONALIZATION
+ if (!sink->multi_sink.fontset) XtError("Aborting: no fontset found\n");
+#endif
+
sink->multi_sink.insertCursorOn= CreateInsertCursor(XtScreenOfObject(new));
sink->multi_sink.laststate = XawisOff;
sink->multi_sink.cursor_x = sink->multi_sink.cursor_y = 0;
@@ -653,7 +665,9 @@ MaxLines(w, height)
{
MultiSinkObject sink = (MultiSinkObject) w;
int font_height;
- XFontSetExtents *ext = XExtentsOfFontSet(sink->multi_sink.fontset);
+ XFontSetExtents *ext;
+ if (!sink->multi_sink.fontset || !(ext = XExtentsOfFontSet(sink->multi_sink.fontset)))
+ XtError("Aborting: no fontset found\n");
font_height = ext->max_logical_extent.height;
return( ((int) height) / font_height );
@@ -680,7 +694,9 @@ MaxHeight( w, lines )
#endif
{
MultiSinkObject sink = (MultiSinkObject) w;
- XFontSetExtents *ext = XExtentsOfFontSet(sink->multi_sink.fontset);
+ XFontSetExtents *ext;
+ if (!sink->multi_sink.fontset || !(ext = XExtentsOfFontSet(sink->multi_sink.fontset)))
+ XtError("Aborting: no fontset found\n");
return(lines * ext->max_logical_extent.height);
}
@@ -776,7 +792,9 @@ _XawMultiSinkPosToXY( w, pos, x, y )
#endif
{
MultiSinkObject sink = (MultiSinkObject) ((TextWidget)w)->text.sink;
- XFontSetExtents *ext = XExtentsOfFontSet( sink->multi_sink.fontset );
+ XFontSetExtents *ext;
+ if (!sink->multi_sink.fontset || !(ext = XExtentsOfFontSet( sink->multi_sink.fontset )))
+ XtError("Aborting: no fontset found\n");
_XawTextPosToXY( w, pos, x, y );
*y += abs( ext->max_logical_extent.y );
diff --git a/xc/lib/Xaw3d/SmeBSB.c b/xc/lib/Xaw3d/SmeBSB.c
index abf811f..dbb39aa 100644
--- a/xc/lib/Xaw3d/SmeBSB.c
@ -221,82 +95,12 @@ diff --git a/xc/lib/Xaw3d/Tip.c b/xc/lib/Xaw3d/Tip.c
index 888eeac..233cc8d 100644
--- a/xc/lib/Xaw3d/Tip.c
+++ b/xc/lib/Xaw3d/Tip.c
@@ -252,6 +252,12 @@ Cardinal *num_args;
@@ -252,6 +252,8 @@ Cardinal *num_args;
TipWidget tip = (TipWidget)w;
XGCValues values;
+ if (!tip->tip.font) XtError("Aborting: no font found\n");
+#ifdef XAW_INTERNATIONALIZATION
+ if (tip->tip.international && !tip->tip.fontset)
+ XtError("Aborting: no fontset found\n");
+#endif
+
tip->tip.timer = 0;
values.foreground = tip->tip.foreground;
@@ -344,7 +350,10 @@ Region region;
#ifdef XAW_INTERNATIONALIZATION
if (tip->tip.international == True) {
Position ksy = tip->tip.internal_height;
- XFontSetExtents *ext = XExtentsOfFontSet(tip->tip.fontset);
+ XFontSetExtents *ext;
+
+ if (!tip->tip.fontset || !(ext = XExtentsOfFontSet(tip->tip.fontset)))
+ XtError("Aborting: no fontset found\n");
ksy += abs(ext->max_ink_extent.y);
@@ -429,7 +438,10 @@ XawTipInfo *info;
#ifdef XAW_INTERNATIONALIZATION
if (info->tip->tip.international == True) {
XFontSet fset = info->tip->tip.fontset;
- XFontSetExtents *ext = XExtentsOfFontSet(fset);
+ XFontSetExtents *ext;
+
+ if (!fset || !(ext = XExtentsOfFontSet(fset)))
+ XtError("Aborting: no fontset found\n");
height = ext->max_ink_extent.height;
if ((nl = index(label, '\n')) != NULL) {
diff --git a/xc/lib/Xaw3d/XawIm.c b/xc/lib/Xaw3d/XawIm.c
index 2cf2113..0aeb9ac 100644
--- a/xc/lib/Xaw3d/XawIm.c
+++ b/xc/lib/Xaw3d/XawIm.c
@@ -752,8 +752,10 @@ static void CreateIC( w, ve )
SetVaArg( &pe_a[pe_cnt], (XPointer) p->font_set); pe_cnt++;
SetVaArg( &st_a[st_cnt], (XPointer) XNFontSet); st_cnt++;
SetVaArg( &st_a[st_cnt], (XPointer) p->font_set); st_cnt++;
- height = maxAscentOfFontSet(p->font_set)
- + maxDescentOfFontSet(p->font_set);
+ if (p->font_set) {
+ height = maxAscentOfFontSet(p->font_set)
+ + maxDescentOfFontSet(p->font_set);
+ }
height = SetVendorShellHeight(ve, height);
}
if (p->flg & CIFg) {
@@ -884,7 +886,7 @@ static void SetICValues( w, ve, focus )
XPointer ic_a[20], pe_a[20], st_a[20];
int ic_cnt = 0, pe_cnt = 0, st_cnt = 0;
XawTextMargin *margin;
- int height;
+ int height = 0;
if ((ve->im.xim == NULL) || ((p = GetIcTableShared(w, ve)) == NULL) ||
(p->xic == NULL)) return;
@@ -911,8 +913,10 @@ static void SetICValues( w, ve, focus )
SetVaArg( &pe_a[pe_cnt], (XPointer) p->font_set); pe_cnt++;
SetVaArg( &st_a[st_cnt], (XPointer) XNFontSet); st_cnt++;
SetVaArg( &st_a[st_cnt], (XPointer) p->font_set); st_cnt++;
- height = maxAscentOfFontSet(p->font_set)
- + maxDescentOfFontSet(p->font_set);
+ if (p->font_set) {
+ height = maxAscentOfFontSet(p->font_set)
+ + maxDescentOfFontSet(p->font_set);
+ }
height = SetVendorShellHeight(ve, height);
}
if (p->flg & CIFg) {
--
1.6.1

View File

@ -1,7 +1,7 @@
Summary: A version of the MIT Athena widget set for X
Name: Xaw3d
Version: 1.5E
Release: 18%{?dist}
Release: 19%{?dist}
Group: System Environment/Libraries
Source: ftp://ftp.visi.com/users/hawkeyd/X/Xaw3d-%{version}.tar.gz
Patch: Xaw3d-1.5E-xorg-imake.patch
@ -123,6 +123,9 @@ rm -rf $RPM_BUILD_ROOT
%{_includedir}/X11/Xaw3d
%changelog
* Wed Dec 1 2010 Hans de Goede <hdegoede@redhat.com> - 1.5E-19
- Do not make missing font sets a fatal error (#658526)
* Tue Nov 9 2010 Hans de Goede <hdegoede@redhat.com> - 1.5E-18
- Drop Xaw3d-1.5E-lex.patch it was not applied for a reason (#587349)