Permalink
Browse files

Use strcpy rather than strdup (#5610)

  • Loading branch information...
geographika authored and rouault committed Jun 15, 2018
1 parent 3e50226 commit af14610814835692a6ce9bc6a5149d8aaaa247af
Showing with 15 additions and 11 deletions.
  1. +15 −11 mapstring.c
@@ -2103,22 +2103,26 @@ int msStringIsInteger(const char *string)
/* Safe version of msStrdup(). This function is taken from gdal/cpl. */
char *msStrdup( const char * pszString )
char *msStrdup(const char * pszString)
{
char *pszReturn;
size_t nStringLength;
char *pszReturn;
if( pszString == NULL )
pszString = "";
if (pszString == NULL)
pszString = "";
pszReturn = strdup( pszString );
nStringLength = strlen(pszString) + 1; /* null terminated byte */
pszReturn = malloc(nStringLength);
if( pszReturn == NULL ) {
fprintf(stderr, "msSmallMsStrdup(): Out of memory allocating %ld bytes.\n",
(long) strlen(pszString) );
exit(1);
}
if (pszReturn == NULL) {
fprintf(stderr, "msSmallMalloc(): Out of memory allocating %ld bytes.\n",
(long)strlen(pszString));
exit(1);
}
memcpy(pszReturn, pszString, nStringLength);
return( pszReturn );
return pszReturn;
}

0 comments on commit af14610

Please sign in to comment.