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>
This commit is contained in:
parent
d9243777c7
commit
03ddca6f71
|
@ -800,20 +800,17 @@ void InitOutput(ScreenInfo *pScreenInfo, int argc, char *argv[])
|
||||||
/* RATS: Assuming the fp string (which comes from the command-line argv
|
/* RATS: Assuming the fp string (which comes from the command-line argv
|
||||||
vector) is NULL-terminated, the buffer is large enough for the
|
vector) is NULL-terminated, the buffer is large enough for the
|
||||||
strcpy. */
|
strcpy. */
|
||||||
static void dmxSetDefaultFontPath(char *fp)
|
static void dmxSetDefaultFontPath(const char *fp)
|
||||||
{
|
{
|
||||||
int fplen = strlen(fp) + 1;
|
|
||||||
|
|
||||||
if (dmxFontPath) {
|
if (dmxFontPath) {
|
||||||
int len;
|
int fplen = strlen(fp) + 1;
|
||||||
|
int len = strlen(dmxFontPath);
|
||||||
|
|
||||||
len = strlen(dmxFontPath);
|
|
||||||
dmxFontPath = realloc(dmxFontPath, len+fplen+1);
|
dmxFontPath = realloc(dmxFontPath, len+fplen+1);
|
||||||
dmxFontPath[len] = ',';
|
dmxFontPath[len] = ',';
|
||||||
strncpy(&dmxFontPath[len+1], fp, fplen);
|
strncpy(&dmxFontPath[len+1], fp, fplen);
|
||||||
} else {
|
} else {
|
||||||
dmxFontPath = malloc(fplen);
|
dmxFontPath = strdup(fp);
|
||||||
strncpy(dmxFontPath, fp, fplen);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
defaultFontPath = dmxFontPath;
|
defaultFontPath = dmxFontPath;
|
||||||
|
|
Loading…
Reference in New Issue