Browse Source

Check the stat structure only if it has been initialized

For non-existing files the stat structure is not initialized and S_ISDIR would
randomly return true leading to the "Cannot divert directories" error
message.

This fixes the test-suite on i386.
Raphaël Hertzog 16 years ago
parent
commit
611e323562
1 changed files with 2 additions and 1 deletions
  1. 2 1
      src/divertcmd.c

+ 2 - 1
src/divertcmd.c

@@ -427,7 +427,8 @@ diversion_add(const char *const *argv)
 	file_init(&file_from, filename);
 	file_init(&file_from, filename);
 	file_stat(&file_from);
 	file_stat(&file_from);
 
 
-	if (S_ISDIR(file_from.stat.st_mode))
+	if (file_from.stat_state == file_stat_valid &&
+	    S_ISDIR(file_from.stat.st_mode))
 		badusage(_("Cannot divert directories"));
 		badusage(_("Cannot divert directories"));
 
 
 	fnn_from = findnamenode(filename, 0);
 	fnn_from = findnamenode(filename, 0);