In my example, strcpy_s and malloc_s throw an error while manual copying seems to work. here's the code. This works:
hookaddrinfoluacode=(char *)malloc(16384);
// This works
for(i=0;i<strlen(this_token);++i){
hookaddrinfoluacode[i]=this_token[i];
}
hookaddrinfoluacode[i+1]='\0';
This doesn't
memcpy_s(hookaddrinfoluacode,sizeof(char),this_token,strlen(this_token));
And neither does this:
strcpy_s(hookaddrinfoluacode,strlen(this_token),this_token);
The error seems to be thrown from this code line in standard library:
_VALIDATE_RETURN_ERRCODE(dst != NULL, EINVAL);
this_token is obtained from this_token=strtok_s(NULL,":",&next_token);
call.
I'm confused :)