From: Jon Trulson Date: Sat, 31 Mar 2018 23:34:40 +0000 (-0600) Subject: dtfile/Main.c: coverity CID 89623; uninit var X-Git-Tag: 2.2.4a~163 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=a8102e85e02e8d74e0c27655d5af33f7e97ab10f;p=oweals%2Fcde.git dtfile/Main.c: coverity CID 89623; uninit var --- diff --git a/cde/programs/dtfile/Main.c b/cde/programs/dtfile/Main.c index c5b1da87..4f3adb62 100644 --- a/cde/programs/dtfile/Main.c +++ b/cde/programs/dtfile/Main.c @@ -3420,17 +3420,16 @@ static void GetPWD( char current_directory[] ) { - FILE * pwd_file; - register int i; + FILE * pwd_file = NULL; + int i = 0; /* Open a pwd process and read the current working directory */ /* from it. If the open fails or a read fails, then display */ /* the users home directory. */ pwd_file = popen ("pwd", "r"); - i = 0; - if (pwd_file != NULL) + if (pwd_file) { while (1) { @@ -3449,9 +3448,11 @@ GetPWD( i++; } } - (void) pclose (pwd_file); - current_directory[i] = '\0'; + if (pwd_file) + pclose (pwd_file); + + current_directory[i] = '\0'; } /************************************************************************