浏览代码

fix from Bryan Wu: return NULL upon error, not the NULL string

Mike Frysinger 17 年之前
父节点
当前提交
4a38f88b2c
共有 1 个文件被更改,包括 3 次插入4 次删除
  1. 3 4
      libc/stdlib/mkdtemp.c

+ 3 - 4
libc/stdlib/mkdtemp.c

@@ -29,10 +29,9 @@
    (This function comes from OpenBSD.) */
    (This function comes from OpenBSD.) */
 char * mkdtemp (char *template)
 char * mkdtemp (char *template)
 {
 {
-    if (__gen_tempname (template, __GT_DIR))
-	/* We return the null string if we can't find a unique file name.  */
-	template[0] = '\0';
-
+  if (__gen_tempname (template, __GT_DIR))
+    return NULL;
+  else
     return template;
     return template;
 }
 }
 #endif
 #endif