The program will return a set of string “This is James: 00:00:00” and a time format but it crashed. I believe there is a missing memory allocation but couldn’t pin where the error is.
FREObject result = 0;
uint32_t len = -1;
const uint8_t *str = 0;
char *temp;
uint8_t *strAll;
time_t curtime;
struct tm *loctime;
/* Get the current time. */
curtime = time(NULL);
/* Convert it to local time representation. */
loctime = localtime(&curtime);
//Turn our actionscrpt code into native code.
if(FREGetObjectAsUTF8(argv[0], &len, &str) == FRE_OK) {
temp = "Hello World! This is ";
strAll = (char *)malloc(sizeof(temp) + sizeof(str) + sizeof(loctime));
strcpy(strAll,temp);
strcat(strAll,str);
strcat(strAll,asctime(loctime));
}
You probably want
strleninstead ofsizeofhere:Also the
sizeof(loctime)makes very little sense. You probably want to replace it with the length ofasctime(loctime).Maybe something like this: