[PATCH xserver v2 3/3] xfree86: drop unneeded strdup for modulepath/logfile

Emil Velikov emil.l.velikov at gmail.com
Mon May 2 22:47:22 UTC 2016


The destination variable is never freed, thus we even plug some memory
leaks.

v2: Rebase against updated xf86CheckPrivs() helper.

Signed-off-by: Emil Velikov <emil.l.velikov at gmail.com>
---
 hw/xfree86/common/xf86Init.c | 14 ++------------
 1 file changed, 2 insertions(+), 12 deletions(-)

diff --git a/hw/xfree86/common/xf86Init.c b/hw/xfree86/common/xf86Init.c
index 1f7615d..202e9cc 100644
--- a/hw/xfree86/common/xf86Init.c
+++ b/hw/xfree86/common/xf86Init.c
@@ -1121,26 +1121,16 @@ ddxProcessArgument(int argc, char **argv, int i)
 
     /* First the options that are not allowed with elevated privileges */
     if (!strcmp(argv[i], "-modulepath")) {
-        char *mp;
-
         CHECK_FOR_REQUIRED_ARGUMENT();
         xf86CheckPrivs(argv[i], argv[i + 1]);
-        mp = strdup(argv[i + 1]);
-        if (!mp)
-            FatalError("Can't allocate memory for ModulePath\n");
-        xf86ModulePath = mp;
+        xf86ModulePath = argv[i + 1];
         xf86ModPathFrom = X_CMDLINE;
         return 2;
     }
     if (!strcmp(argv[i], "-logfile")) {
-        char *lf;
-
         CHECK_FOR_REQUIRED_ARGUMENT();
         xf86CheckPrivs(argv[i], argv[i + 1]);
-        lf = strdup(argv[i + 1]);
-        if (!lf)
-            FatalError("Can't allocate memory for LogFile\n");
-        xf86LogFile = lf;
+        xf86LogFile = argv[i + 1];
         xf86LogFileFrom = X_CMDLINE;
         return 2;
     }
-- 
2.8.0



More information about the xorg-devel mailing list