LogoopenSUSE Build Service > Projects
Sign Up | Log In

View File xosview-1.9.2-appdef.dif of Package xosview (Project X11:Utilities)

--- Xrm.cc
+++ Xrm.cc	2012-02-07 16:45:31.561934420 +0000
@@ -9,6 +9,7 @@
 #include <stdio.h>	//  For snprintf().
 #include <ctype.h>
 #include <iostream>
+#include <sys/stat.h>	//  For stat().
 #include <unistd.h>  //  for access(), etc.  BCG
 #include "snprintf.h"
 #include "general.h"
@@ -140,29 +141,34 @@ Listed from weakest to strongest:
 
   //  Merge in the system resource database.
   char rfilename[2048];
+  struct stat st;
   int result;
 
   // Get the app-defaults
+  result = snprintf(rfilename, sizeof rfilename, "/usr/share/X11/app-defaults/%s",
+    XrmQuarkToString(_class));
+  if (result >= 0 && (size_t)result < sizeof rfilename && stat(rfilename, &st) == 0)
+    XrmCombineFileDatabase (rfilename, &_db, 1);
   result = snprintf(rfilename, sizeof rfilename, "/etc/X11/app-defaults/%s",
     XrmQuarkToString(_class));
-  if (rfilename != NULL)
+  if (result >= 0 && (size_t)result < sizeof rfilename && stat(rfilename, &st) == 0)
     XrmCombineFileDatabase (rfilename, &_db, 1);
   result = snprintf(rfilename, sizeof rfilename, "/usr/lib/X11/app-defaults/%s",
     XrmQuarkToString(_class));
-  if (result >= 0 && result < sizeof rfilename)
+  if (result >= 0 && (size_t)result < sizeof rfilename && stat(rfilename, &st) == 0)
     XrmCombineFileDatabase (rfilename, &_db, 1);
   result = snprintf(rfilename, sizeof rfilename, "/usr/X11R6/lib/X11/app-defaults/%s",
     XrmQuarkToString(_class));
-  if (result >= 0 && result < sizeof rfilename)
+  if (result >= 0 && (size_t)result < sizeof rfilename && stat(rfilename, &st) == 0)
     XrmCombineFileDatabase (rfilename, &_db, 1);
   //  Try a few more, for SunOS/Solaris folks.
   result = snprintf(rfilename, sizeof rfilename, "/usr/openwin/lib/X11/app-defaults/%s",
     XrmQuarkToString(_class));
-  if (result >= 0 && result < sizeof rfilename)
+  if (result >= 0 && (size_t)result < sizeof rfilename && stat(rfilename, &st) == 0)
     XrmCombineFileDatabase (rfilename, &_db, 1);
   result = snprintf(rfilename, sizeof rfilename, "/usr/local/X11R6/lib/X11/app-defaults/%s",
       XrmQuarkToString(_class));
-  if (result >= 0 && result < sizeof rfilename)
+  if (result >= 0 && (size_t)result < sizeof rfilename && stat(rfilename, &st) == 0)
     XrmCombineFileDatabase (rfilename, &_db, 1);
 
   //  Now, check for an XOSView file in the XAPPLRESDIR directory...