Hi,

The first patch fixes segfault, which sometimes happen when
using UTF-8 locales. Specifically this seems to fix the bug,
which was reported by Antonis: 

When a UTF locale is enabled the user can not change the Font size in
the preferences. If you do, and say go to size 3 from the default 4,
dtwm will not load

(https://sourceforge.net/p/cdesktopenv/mailman/message/31836182/
there is no ticket for this bug).

The second one fixed segfault in dtprintinfo on UTF-8 locales.

Both bugs are results of the  same problem: not checking of
XmeRenderTableGetDefaultFont() return value.


Regards,
Eugene
>From e1277b23b7ba5b2c1e836a35328871d532dbd0bf Mon Sep 17 00:00:00 2001
From: Eugene Doudine <dudi...@gmail.com>
Date: Fri, 21 Feb 2014 13:34:04 +0200
Subject: [PATCH 1/2] Fix for several segfaults in dtwm that happen with UTF-8
 locale and were caused by unckeked
 XmeRenderTableGetDefaultFont return value

---
 cde/lib/DtWidget/Control.c |   12 +++++++-----
 cde/programs/dtwm/Clock.c  |   11 ++++++++---
 2 files changed, 15 insertions(+), 8 deletions(-)

diff --git a/cde/lib/DtWidget/Control.c b/cde/lib/DtWidget/Control.c
index dc414a7..a57dc3f 100644
--- a/cde/lib/DtWidget/Control.c
+++ b/cde/lib/DtWidget/Control.c
@@ -1716,7 +1716,6 @@ UpdateGCs(
   XtGCMask		value_mask;
   XmManagerWidget	mw = (XmManagerWidget) XtParent(g);
   XFontStruct *		font;
-  Boolean		font_rtn;
   
   if (!G__DoUpdate (g))
     return;
@@ -1736,16 +1735,19 @@ UpdateGCs(
   
   /*	Get normal GC.
    */
-  font_rtn = XmeRenderTableGetDefaultFont (G_FontList (g), &font);
-  value_mask = GCForeground | GCBackground | GCFont | GCFillStyle;
+  value_mask = GCForeground | GCBackground | GCFillStyle;
+  if (XmeRenderTableGetDefaultFont (G_FontList (g), &font)) {
+    value_mask |= GCFont;
+    values.font = font->fid;    
+  }
+
   if (G_UseEmbossedText (g))
     values.foreground = WhitePixelOfScreen (XtScreen (g));
   else
     values.foreground = G_Foreground (g);
   values.background = G_Background (g);
-  
   values.fill_style = FillSolid;
-  values.font = font->fid;
+
   G_NormalGC (g) = XtGetGC ((Widget)mw, value_mask, &values);
   
   /*	Get top shadow GC.
diff --git a/cde/programs/dtwm/Clock.c b/cde/programs/dtwm/Clock.c
index 7d7dea8..0bc38a8 100644
--- a/cde/programs/dtwm/Clock.c
+++ b/cde/programs/dtwm/Clock.c
@@ -1027,8 +1027,13 @@ else if (G_ClockHandGC (g))
 
 /*	Get clock hand GC.
 */
-font_rtn = XmeRenderTableGetDefaultFont (G_FontList (g), &font);
-value_mask = GCForeground | GCFont | GCFillStyle;
+
+value_mask = GCForeground | GCFillStyle;
+
+if (XmeRenderTableGetDefaultFont (G_FontList (g), &font)) {
+  value_mask |= GCFont;
+  values.font = font->fid;
+}
 
 if (((G_PixmapForeground (g) == WhitePixelOfScreen (XtScreen (g))) &&
      (G_PixmapBackground (g) == BlackPixelOfScreen (XtScreen (g)))) ||
@@ -1038,7 +1043,7 @@ if (((G_PixmapForeground (g) == WhitePixelOfScreen (XtScreen (g))) &&
 else
     values.foreground = mw->manager.top_shadow_color;
 values.fill_style = FillSolid;
-values.font = font->fid;
+
 
 G_ClockHandGC (g) = XtGetGC ((Widget) mw, value_mask, &values);
 
-- 
1.7.9.5

>From 5b4c88ee8e1c80a424a7c26d33e420d95bf830f2 Mon Sep 17 00:00:00 2001
From: Eugene Doudine <dudi...@gmail.com>
Date: Fri, 21 Feb 2014 13:52:25 +0200
Subject: [PATCH 2/2] Fixes segfault in dtprintinfo when used UTF-8 locale,
 bug was caused by unchecked return value of
 XmeRenderTableGetDefaultFont()

---
 .../dtprintinfo/libUI/MotifUI/Application.C        |    9 ++++++---
 cde/programs/dtprintinfo/libUI/MotifUI/DtDND.C     |    4 +++-
 2 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/cde/programs/dtprintinfo/libUI/MotifUI/Application.C b/cde/programs/dtprintinfo/libUI/MotifUI/Application.C
index 33d4c36..383c6a7 100644
--- a/cde/programs/dtprintinfo/libUI/MotifUI/Application.C
+++ b/cde/programs/dtprintinfo/libUI/MotifUI/Application.C
@@ -96,7 +96,7 @@ static XrmOptionDescRec options[] =
 };
 
 extern "C" {
-   extern void XmeRenderTableGetDefaultFont(XmFontList, XFontStruct **);
+   extern Boolean XmeRenderTableGetDefaultFont(XmFontList, XFontStruct **);
 } 
 
 Application::Application(char *name,
@@ -151,9 +151,12 @@ Application::Application(char *name,
 	   {
 	     XmFontType _type_return;
 	     fs = (XFontStruct *)XmFontListEntryGetFont(entry, &_type_return);
-	     if (_type_return != XmFONT_IS_FONT)
+	     if (_type_return != XmFONT_IS_FONT) {
 	       XmeRenderTableGetDefaultFont(userFont, &fs);
-	     font = fs->fid;
+	     }
+	     if (fs) {
+	       font = fs->fid;
+	     }
 	   }
 	 XmFontListFreeFontContext(context);
        }
diff --git a/cde/programs/dtprintinfo/libUI/MotifUI/DtDND.C b/cde/programs/dtprintinfo/libUI/MotifUI/DtDND.C
index 1c0631c..3316a3e 100644
--- a/cde/programs/dtprintinfo/libUI/MotifUI/DtDND.C
+++ b/cde/programs/dtprintinfo/libUI/MotifUI/DtDND.C
@@ -93,7 +93,9 @@ DtDND::DtDND(MotifUI *_obj, DNDCallback _dndCB, boolean _can_drop_on_root)
       gc = XCreateGC(tmp->display, tmp_pixmap, 0, NULL);
       tmp_pixmap = XCreatePixmap(tmp->display, tmp->root, 1, 1, 1);
       gc_mask = XCreateGC(tmp->display, tmp_pixmap, 0, NULL);
-      XSetFont(tmp->display, gc, tmp->font);
+      if (tmp->font) {
+	XSetFont(tmp->display, gc, tmp->font);
+      }
       FirstTime = false;
     }
 
-- 
1.7.9.5

------------------------------------------------------------------------------
Managing the Performance of Cloud-Based Applications
Take advantage of what the Cloud has to offer - Avoid Common Pitfalls.
Read the Whitepaper.
http://pubads.g.doubleclick.net/gampad/clk?id=121054471&iu=/4140/ostg.clktrk
_______________________________________________
cdesktopenv-devel mailing list
cdesktopenv-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/cdesktopenv-devel

Reply via email to