Have written a function as follows....I am getting an error when I try to free the allocated memory through malloc...
Have put in a commment against the Free functions that are returning an error

Please HELP!

CString getLogFilename()
{
int x,temp;
char *yyyy = (char *)malloc(4);
char *mm = (char *)malloc(2);
char *dd = (char *)malloc(2);
char *zeroCat = (char *)malloc(2);
strcpy(zeroCat,"0");

CTime t = CTime::GetCurrentTime();

CString filename;

char appendDate[8];

/* get the year in yyyy format*/
x = t.GetYear();
_itoa(x,yyyy,10);

/* get the Month in mm format */
x = t.GetMonth();
_itoa(x,mm,10);
if(strlen(mm) == 1){
strcat(zeroCat,mm);
strcpy(mm,zeroCat);
strcpy(zeroCat,"0");
}


/* get the Day in dd format */
x = t.GetDay();
_itoa(x,dd,10);
if(strlen(dd) == 1){
strcat(zeroCat,dd);
strcpy(dd,zeroCat);
}

strcpy(appendDate,yyyy);
strcat(appendDate,mm);
strcat(appendDate,dd);

filename = appendDate;

free(yyyy); /*Error */
free(mm); /*Error */
free(dd); /*Error */
free(zeroCat); /*Error */
free(appendDate); /*Error */

return filename;
}