AWARE SYSTEMS
TIFF and LibTiff Mail List Archive

Thread

2000.11.07 19:59 "Win32 not properly closing files", by Peter Montgomery
2000.11.08 15:56 "Re: Win32 not properly closing files", by Ledoux
2000.11.08 18:09 "Re: Win32 not properly closing files", by
2000.11.09 18:30 "Re: Win32 not properly closing files", by Peter Montgomery

2000.11.09 18:30 "Re: Win32 not properly closing files", by Peter Montgomery

Mea culpa! Yes, the bug is in my code after all. Here's the code snippet that wasn't working...

 Tif = TIFFOpen(FileInfo->FullFileName, "r");

 if (Tif){
  TIFFClose(Tif);
  Tif = NULL;
 }

Seems pretty simple, right? Really nothing to go wrong here. However, I forgot that this application I wrote does a separate file open/read the header and get info/file close in a totally separate function that other parts of the code can (and do) call. Thus, even though the code here was perfect, it turns out that the code in the "read the header and get info" function wasn't using TIFFClose() but using the normal fclose() function. In this particular case, the error was being suppressed (since fclose() was trying to close a NULL file handle) and I didn't know that I had a wee bug in my code.

    Sorry to have pestered the list with a question that ultimately

pointed to a bug in my code, but frankly the suggestions on this list (particularly Ledoux's suggestion to use "ru" instead of "r") enabled me to find my bug.

    Thanks,
    PeterM