diff --git a/magick/nt-base.c b/magick/nt-base.c index 34347c407f..da160b2e2a 100644 --- a/magick/nt-base.c +++ b/magick/nt-base.c @@ -1752,23 +1752,16 @@ MagickPrivate DIR *NTOpenDirectory(const char *path) MaxTextExtent); if (length == 0) return((DIR *) NULL); + if(wcsncat(file_specification,L"\\*.*",MaxTextExtent-wcslen( + file_specification)-1) == (wchar_t*) NULL) + return((DIR *) NULL); entry=(DIR *) AcquireCriticalMemory(sizeof(DIR)); entry->firsttime=TRUE; entry->hSearch=FindFirstFileW(file_specification,&entry->Win32FindData); if (entry->hSearch == INVALID_HANDLE_VALUE) { - if(wcsncat(file_specification,L"\\*.*",MaxTextExtent-wcslen( - file_specification)-1) == (wchar_t*) NULL) - { - entry=(DIR *) RelinquishMagickMemory(entry); - return((DIR *) NULL); - } - entry->hSearch=FindFirstFileW(file_specification,&entry->Win32FindData); - if (entry->hSearch == INVALID_HANDLE_VALUE) - { - entry=(DIR *) RelinquishMagickMemory(entry); - return((DIR *) NULL); - } + entry=(DIR *) RelinquishMagickMemory(entry); + return((DIR *) NULL); } return(entry); }