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

vl: avoid closing stdout with 'writeconfig'

'writeconfig' supports output to stdout (with '-'); when that happens,
we must not close stdout, or further command line options that also use
stdout will be impacted. (Although 'writeconfig' was copied from
'readconfig', the latter does not have the problem because it does not
support reading from '-')

Signed-off-by: Chen Gang <gang.chen.5i5j@gmail.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
Chen Gang 11 лет назад
Родитель
Сommit
7fb8b5d9c4
1 измененных файлов с 3 добавлено и 1 удалено
  1. 3 1
      vl.c

+ 3 - 1
vl.c

@@ -3890,7 +3890,9 @@ int main(int argc, char **argv, char **envp)
                         }
                         }
                     }
                     }
                     qemu_config_write(fp);
                     qemu_config_write(fp);
-                    fclose(fp);
+                    if (fp != stdout) {
+                        fclose(fp);
+                    }
                     break;
                     break;
                 }
                 }
             case QEMU_OPTION_qtest:
             case QEMU_OPTION_qtest: