From 03ddca6f71339fad089c56484bf35c63642ae1be Mon Sep 17 00:00:00 2001 From: Alan Coopersmith Date: Fri, 28 Oct 2011 21:25:20 -0700 Subject: Convert dmxSetDefaultFontPath to use strdup instead of malloc+strncpy Signed-off-by: Alan Coopersmith Reviewed-by: Jeremy Huddleston --- hw/dmx/dmxinit.c | 11 ++++------- 1 file 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; -- cgit v1.2.3