summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Miller <mtmiller@ieee.org>2016-12-25 09:38:04 +0800
committerMike Miller <mtmiller@debian.org>2016-12-25 09:38:04 +0800
commitfcdf8de3beb6b182bcdf68754f450400fcb5d4c8 (patch)
treeacbdc5832a8c6bf689d43266d865294fc21920b3
parent764f026336d13640db9f1fd6c1173cbebe0c4314 (diff)
Fix FTBFS when PATH_MAX is not defined, e.g. on GNU Hurd
Forwarded: no Last-Update: 2013-10-30 Gbp-Pq: Name 10_no_path_max.patch
-rw-r--r--src/cdargs.cc12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/cdargs.cc b/src/cdargs.cc
index d3fb383..d89130d 100644
--- a/src/cdargs.cc
+++ b/src/cdargs.cc
@@ -930,8 +930,12 @@ string get_resultfile(void) {
}
char* get_cwd_as_charp(void) {
- char buf[PATH_MAX];
- char* result = getcwd(buf, sizeof(buf));
+ char *buf;
+ char *result = NULL;
+
+ size_t size = (size_t)pathconf(".", _PC_PATH_MAX);
+ if ((buf = (char *)malloc(size)) != NULL)
+ result = getcwd(buf, size);
if(result == NULL) {
message("cannot determine current working directory.exit.");
@@ -940,7 +944,9 @@ char* get_cwd_as_charp(void) {
}
/* this can be a memleak if not freed again */
/* but then ... how long does cdargs usually run? */
- return strdup(buf);
+ result = strdup(buf);
+ free(buf);
+ return result;
}
string get_cwd_as_string(void) {