Use strdup() instead of malloc(strlen()+1); memcpy() pairs

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
This commit is contained in:
Alan Coopersmith
2024-03-10 15:32:12 -07:00
parent 4c5ce451f0
commit cc2f4d685f

View File

@@ -949,16 +949,13 @@ SiSOptions(ScrnInfoPtr pScrn)
free(tempstr); free(tempstr);
} }
if((strptr = (char *)xf86GetOptValString(pSiS->Options, OPTION_METAMODES))) { if((strptr = (char *)xf86GetOptValString(pSiS->Options, OPTION_METAMODES))) {
pSiS->MetaModes = malloc(strlen(strptr) + 1); pSiS->MetaModes = strdup(strptr);
if(pSiS->MetaModes) memcpy(pSiS->MetaModes, strptr, strlen(strptr) + 1);
} }
if((strptr = (char *)xf86GetOptValString(pSiS->Options, OPTION_CRT2HSYNC))) { if((strptr = (char *)xf86GetOptValString(pSiS->Options, OPTION_CRT2HSYNC))) {
pSiS->CRT2HSync = malloc(strlen(strptr) + 1); pSiS->CRT2HSync = strdup(strptr);
if(pSiS->CRT2HSync) memcpy(pSiS->CRT2HSync, strptr, strlen(strptr) + 1);
} }
if((strptr = (char *)xf86GetOptValString(pSiS->Options, OPTION_CRT2VREFRESH))) { if((strptr = (char *)xf86GetOptValString(pSiS->Options, OPTION_CRT2VREFRESH))) {
pSiS->CRT2VRefresh = malloc(strlen(strptr) + 1); pSiS->CRT2VRefresh = strdup(strptr);
if(pSiS->CRT2VRefresh) memcpy(pSiS->CRT2VRefresh, strptr, strlen(strptr) + 1);
} }
if((strptr = (char *)xf86GetOptValString(pSiS->Options, OPTION_MERGEDDPI))) { if((strptr = (char *)xf86GetOptValString(pSiS->Options, OPTION_MERGEDDPI))) {
int val1 = 0, val2 = 0; int val1 = 0, val2 = 0;