use load address from elf header if possible
[musl] / src / temp / mktemp.c
index 1462a16..654a279 100644 (file)
@@ -17,7 +17,8 @@ char *__mktemp(char *template)
 
        if (l < 6 || strcmp(template+l-6, "XXXXXX")) {
                errno = EINVAL;
-               return 0;
+               *template = 0;
+               return template;
        }
        clock_gettime(CLOCK_REALTIME, &ts);
        r = ts.tv_nsec + (uintptr_t)&ts / 16 + (uintptr_t)template;
@@ -26,8 +27,9 @@ char *__mktemp(char *template)
                if (access(template, F_OK) < 0) return template;
                r = r * 1103515245 + 12345;
        }
+       *template = 0;
        errno = EEXIST;
-       return 0;
+       return template;
 }
 
 weak_alias(__mktemp, mktemp);