Просмотр исходного кода

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
Родитель
Сommit
611e323562
1 измененных файлов с 2 добавлено и 1 удалено
  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_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"));
 
 	fnn_from = findnamenode(filename, 0);