summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Coopersmith <alan.coopersmith@oracle.com>2011-10-28 21:25:20 -0700
committerAlan Coopersmith <alan.coopersmith@oracle.com>2011-11-23 12:15:05 -0800
commit03ddca6f71339fad089c56484bf35c63642ae1be (patch)
treebd858fb20172edbf62d6a01ba8cb3fbfa77b7740
parentd9243777c77d9b2992fbaf7f459430283837e323 (diff)
Convert dmxSetDefaultFontPath to use strdup instead of malloc+strncpy
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com> Reviewed-by: Jeremy Huddleston <jeremyhu@apple.com>
-rw-r--r--hw/dmx/dmxinit.c11
1 files changed, 4 insertions, 7 deletions
diff --git a/hw/dmx/dmxinit.c b/hw/dmx/dmxinit.c
index b950c50a4..57c242598 100644
--- a/hw/dmx/dmxinit.c
+++ b/hw/dmx/dmxinit.c
@@ -800,20 +800,17 @@ void InitOutput(ScreenInfo *pScreenInfo, int argc, char *argv[])
/* RATS: Assuming the fp string (which comes from the command-line argv
vector) is NULL-terminated, the buffer is large enough for the
strcpy. */
-static void dmxSetDefaultFontPath(char *fp)
+static void dmxSetDefaultFontPath(const 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;