summaryrefslogtreecommitdiff
path: root/libyasm
diff options
context:
space:
mode:
Diffstat (limited to 'libyasm')
-rw-r--r--libyasm/file.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/libyasm/file.c b/libyasm/file.c
index 01359de3..fa225af0 100644
--- a/libyasm/file.c
+++ b/libyasm/file.c
@@ -235,7 +235,7 @@ yasm__getcwd(void)
size = 1024;
buf = yasm_xmalloc(size);
- while (getcwd(buf, size) == NULL) {
+ while (getcwd(buf, size-1) == NULL) {
if (errno != ERANGE) {
yasm__fatal(N_("could not determine current working directory"));
yasm_xfree(buf);
@@ -244,6 +244,13 @@ yasm__getcwd(void)
size *= 2;
buf = yasm_xrealloc(buf, size);
}
+
+ /* append a '/' if not already present */
+ size = strlen(buf);
+ if (buf[size-1] != '\\' && buf[size-1] != '/') {
+ buf[size] = '/';
+ buf[size+1] = '\0';
+ }
return buf;
}