FILE *f1 = NULL;
FILE *f2 = NULL;
char buf[BUF_MAX] = { 0, }; //TODO: How about moving buf to heap instead of stack
-- char realpath1[PATH_MAX_SIZE] = { 0, };
-- char realpath2[PATH_MAX_SIZE] = { 0, };
++ char *src_real_path = NULL;
++ char *dest_real_path = NULL;
size_t num;
int ret = 1;
-- if (!realpath(src, realpath1)) {
-- return 0;
-- }
--
-- if (realpath(dst, realpath2) && !strcmp(realpath1, realpath2)) {
++ src_real_path = realpath(src, NULL);
++ dest_real_path = realpath(dst, NULL);
++ if (!src_real_path || !dest_real_path || !strcmp(src_real_path, dest_real_path)) {
++ if (src_real_path)
++ free(src_real_path);
++ if (dest_real_path)
++ free(dest_real_path);
return 0;
}
fclose(f1);
fclose(f2);
--
++ free(src_real_path);
++ free(dest_real_path);
return ret;
}