#include <sys/types.h>
#ifdef _MSC_VER
+#include <direct.h>
int mkstemp (char *tmp_template);
#endif
}
} while (fail);
- return r;
+ /* On amd64 sometimes the bottom 32-bits of r == the bottom 32-bits of buffer
+ * but the top 32-bits of r have overflown to 0xffffffff (seriously wtf getcwd
+ * so we return the buffer here since it has a pointer to the valid string
+ */
+ return buffer;
}