[PATCH 3/5] Convert dmxSetDefaultFontPath to use strdup instead of malloc+strncpy

Alan Coopersmith alan.coopersmith at oracle.com
Fri Oct 28 21:41:51 PDT 2011


Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com>
---
 hw/dmx/dmxinit.c |    9 +++------
 1 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/hw/dmx/dmxinit.c b/hw/dmx/dmxinit.c
index b950c50..9a60bf3 100644
--- a/hw/dmx/dmxinit.c
+++ b/hw/dmx/dmxinit.c
@@ -802,18 +802,15 @@ void InitOutput(ScreenInfo *pScreenInfo, int argc, char *argv[])
          strcpy. */ 
 static void dmxSetDefaultFontPath(char *fp)
 {
-    int fplen = strlen(fp) + 1;
-    
     if (dmxFontPath) {
-	int len;
+	int fplen = strlen(fp) + 1;
+	int len = strlen(dmxFontPath);
 
-	len = strlen(dmxFontPath);
 	dmxFontPath = realloc(dmxFontPath, len+fplen+1);
 	dmxFontPath[len] = ',';
 	strncpy(&dmxFontPath[len+1], fp, fplen);
     } else {
-	dmxFontPath = malloc(fplen);
-	strncpy(dmxFontPath, fp, fplen);
+	dmxFontPath = strdup(fp);
     }
 
     defaultFontPath = dmxFontPath;
-- 
1.7.3.2



More information about the xorg-devel mailing list