*/
char *phar_fix_filepath(char *path, int *new_len, int use_cwd TSRMLS_DC) /* {{{ */
{
- char newpath[MAXPATHLEN];
+ char *newpath;
int newpath_len;
char *ptr;
char *tok;
if (PHAR_G(cwd_len) && use_cwd && path_length > 2 && path[0] == '.' && path[1] == '/') {
newpath_len = PHAR_G(cwd_len);
+ newpath = emalloc(strlen(path) + newpath_len + 1);
memcpy(newpath, PHAR_G(cwd), newpath_len);
} else {
+ newpath = emalloc(strlen(path) + 2);
newpath[0] = '/';
newpath_len = 1;
}
if (*tok == '.') {
efree(path);
*new_len = 1;
+ efree(newpath);
return estrndup("/", 1);
}
break;
if (tok[0] == '.' && tok[1] == '.') {
efree(path);
*new_len = 1;
+ efree(newpath);
return estrndup("/", 1);
}
}
+ efree(newpath);
return path;
}
efree(path);
*new_len = newpath_len;
- return estrndup(newpath, newpath_len);
+ newpath[newpath_len] = '\0';
+ return erealloc(newpath, newpath_len + 1);
}
/* }}} */