summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaulo Cesar Pereira de Andrade <pcpa@mandriva.com.br>2008-05-01 01:02:39 -0300
committerPeter Hutterer <peter@cs.unisa.edu.au>2008-05-01 15:55:15 +0930
commit01c61f3d972fc2f4e5bb536dd00d8b6bbeb0fb3d (patch)
tree2c8005ce5d1aaaa29bbcb179004bd2f1d5a03d6b
parent6899ff81e8f668382e3e2f9afdd9cdf51d0e0f7d (diff)
xorgcfg: Fix a crash if xorg.conf doesn't have a Files section.
This patch only creates a Files section if required, so if no entries are added, an empty Files section will not be created. Signed-off-by: Peter Hutterer <peter@cs.unisa.edu.au>
-rw-r--r--hw/xfree86/utils/xorgcfg/expert.c50
1 files changed, 34 insertions, 16 deletions
diff --git a/hw/xfree86/utils/xorgcfg/expert.c b/hw/xfree86/utils/xorgcfg/expert.c
index bb6960ce7..484c2ec4b 100644
--- a/hw/xfree86/utils/xorgcfg/expert.c
+++ b/hw/xfree86/utils/xorgcfg/expert.c
@@ -465,7 +465,7 @@ CreateFiles(TreeNode *files)
Widget w;
char *value;
- value = file->file_logfile ? file->file_logfile : "";
+ value = (file && file->file_logfile) ? file->file_logfile : "";
node = NewNode(files, NULL, NULL, files->node,
(TreeData*)XtCalloc(1, sizeof(TreeData)));
CreateFilesField(node, "LogFile", value);
@@ -509,10 +509,14 @@ UpdateFiles(TreeNode *files)
/* LogFile */
files = files->child;
XtVaGetValues(files->data->files.text, XtNstring, &str, NULL);
- XtFree(XF86Config->conf_files->file_logfile);
- if (*str)
+ if (XF86Config->conf_files && XF86Config->conf_files->file_logfile)
+ XtFree(XF86Config->conf_files->file_logfile);
+ if (*str) {
+ if (XF86Config->conf_files == NULL)
+ XF86Config->conf_files = XtCalloc(1, sizeof(XF86ConfFilesRec));
XF86Config->conf_files->file_logfile = XtNewString(str);
- else
+ }
+ else if (XF86Config->conf_files)
XF86Config->conf_files->file_logfile = NULL;
}
@@ -527,10 +531,11 @@ CreateFontPath(TreeNode *fontpath, char *path)
if (path == NULL) {
if (XF86Font_path) {
path = XtNewString(XF86Font_path);
- if (XF86Config->conf_files && XF86Config->conf_files->file_fontpath) {
+ if (XF86Config->conf_files && XF86Config->conf_files->file_fontpath)
XtFree(XF86Config->conf_files->file_fontpath);
- XF86Config->conf_files->file_fontpath = XtNewString(path);
- }
+ if (XF86Config->conf_files == NULL)
+ XF86Config->conf_files = XtCalloc(1, sizeof(XF86ConfFilesRec));
+ XF86Config->conf_files->file_fontpath = XtNewString(path);
}
else if (XF86Config->conf_files && XF86Config->conf_files->file_fontpath)
path = XtNewString(XF86Config->conf_files->file_fontpath);
@@ -629,9 +634,14 @@ FontPathChanged(TreeNode *node)
pos += len - 2;
}
- if (XF86Config->conf_files->file_fontpath)
- XtFree(XF86Config->conf_files->file_fontpath);
- XF86Config->conf_files->file_fontpath = fontpath;
+ if (XF86Config->conf_files) {
+ if (XF86Config->conf_files->file_fontpath)
+ XtFree(XF86Config->conf_files->file_fontpath);
+ }
+ else if (fontpath)
+ XF86Config->conf_files = XtCalloc(1, sizeof(XF86ConfFilesRec));
+ if (XF86Config->conf_files)
+ XF86Config->conf_files->file_fontpath = fontpath;
}
static void
@@ -703,10 +713,11 @@ CreateModulePath(TreeNode *modulepath, char *path)
if (path == NULL) {
if (XF86Module_path) {
path = XtNewString(XF86Module_path);
- if (XF86Config->conf_files && XF86Config->conf_files->file_modulepath) {
+ if (XF86Config->conf_files == NULL)
+ XF86Config->conf_files = XtCalloc(1, sizeof(XF86ConfFilesRec));
+ else if (XF86Config->conf_files->file_modulepath)
XtFree(XF86Config->conf_files->file_modulepath);
- XF86Config->conf_files->file_modulepath = XtNewString(path);
- }
+ XF86Config->conf_files->file_modulepath = XtNewString(path);
}
else if (XF86Config->conf_files && XF86Config->conf_files->file_modulepath)
path = XtNewString(XF86Config->conf_files->file_modulepath);
@@ -799,9 +810,14 @@ ModulePathChanged(TreeNode *node)
pos += len - 2;
}
- if (XF86Config->conf_files->file_modulepath)
- XtFree(XF86Config->conf_files->file_modulepath);
- XF86Config->conf_files->file_modulepath = modulepath;
+ if (XF86Config->conf_files) {
+ if (XF86Config->conf_files->file_modulepath)
+ XtFree(XF86Config->conf_files->file_modulepath);
+ }
+ else if (modulepath)
+ XF86Config->conf_files = XtCalloc(1, sizeof(XF86ConfFilesRec));
+ if (XF86Config->conf_files)
+ XF86Config->conf_files->file_modulepath = modulepath;
}
static void
@@ -921,6 +937,8 @@ NewModuleCallback(Widget unused, XtPointer user_data, XtPointer call_data)
DeleteNode(node);
load = (XF86LoadPtr)XtCalloc(1, sizeof(XF86LoadRec));
load->load_name = XtNewString(label);
+ if (XF86Config->conf_modules == NULL)
+ XF86Config->conf_modules = XtCalloc(1, sizeof(XF86ConfModuleRec));
XF86Config->conf_modules->mod_load_lst =
xf86addModule(XF86Config->conf_modules->mod_load_lst, load);