File tree Expand file tree Collapse file tree 2 files changed +16
-8
lines changed
Expand file tree Collapse file tree 2 files changed +16
-8
lines changed Original file line number Diff line number Diff line change @@ -171,19 +171,27 @@ static inline void ffUnsuppressIO(bool* suppressed)
171171
172172void ffListFilesRecursively (const char * path , bool pretty );
173173
174+ static inline bool ffIsValidNativeFD (FFNativeFD fd )
175+ {
176+ #ifndef _WIN32
177+ return fd >= 0 ;
178+ #else
179+ // https://devblogs.microsoft.com/oldnewthing/20040302-00/?p=40443
180+ return fd != INVALID_HANDLE_VALUE && fd != NULL ;
181+ #endif
182+ }
183+
174184FF_C_NONNULL (1 )
175185static inline bool wrapClose (FFNativeFD * pfd )
176186{
177187 assert (pfd );
178188
179- #ifndef WIN32
180- if (* pfd < 0 )
181- return false;
189+ if (!ffIsValidNativeFD (* pfd ))
190+ return false;
191+
192+ #ifndef _WIN32
182193 close (* pfd );
183194 #else
184- // https://devblogs.microsoft.com/oldnewthing/20040302-00/?p=40443
185- if (* pfd == NULL || * pfd == INVALID_HANDLE_VALUE )
186- return false;
187195 CloseHandle (* pfd );
188196 #endif
189197
Original file line number Diff line number Diff line change @@ -891,13 +891,13 @@ static bool printCachedPixel(FFLogoRequestData* requestData)
891891 if (requestData -> type == FF_LOGO_TYPE_IMAGE_KITTY )
892892 {
893893 fd = getCacheFD (requestData , FF_CACHE_FILE_KITTY_COMPRESSED );
894- if (fd == FF_INVALID_FD )
894+ if (! ffIsValidNativeFD ( fd ) )
895895 fd = getCacheFD (requestData , FF_CACHE_FILE_KITTY_UNCOMPRESSED );
896896 }
897897 else if (requestData -> type == FF_LOGO_TYPE_IMAGE_SIXEL )
898898 fd = getCacheFD (requestData , FF_CACHE_FILE_SIXEL );
899899
900- if (fd == FF_INVALID_FD )
900+ if (! ffIsValidNativeFD ( fd ) )
901901 return false;
902902
903903 ffPrintCharTimes ('\n' , options -> paddingTop );
You can’t perform that action at this time.
0 commit comments