mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-10 21:23:58 +01:00
Tweak usage of get_current_working_dir() for tor_malloc() paranoia.
We assume that tor_free() is not required to be compatible with the platform malloc(), so we need to use a strdup here.
This commit is contained in:
parent
bfe740f065
commit
89407bedf8
@ -2350,7 +2350,15 @@ static char *
|
||||
alloc_getcwd(void)
|
||||
{
|
||||
#ifdef HAVE_GET_CURRENT_DIR_NAME
|
||||
return get_current_dir_name();
|
||||
/* Glibc makes this nice and simple for us. */
|
||||
char *cwd = get_current_dir_name();
|
||||
char *result = NULL;
|
||||
if (cwd) {
|
||||
/* We make a copy here, in case tor_malloc() is not malloc(). */
|
||||
result = tor_strdup(cwd);
|
||||
raw_free(cwd); // alias for free to avoid tripping check-spaces.
|
||||
}
|
||||
return result;
|
||||
#else
|
||||
size_t size = 1024;
|
||||
char *buf = NULL;
|
||||
|
Loading…
Reference in New Issue
Block a user