Message-ID: 009e01c04a7b$1b98b780$0201a8c0@pacbell.net
To: tiff@olympiakos.com
Subject: Re: Win32 not properly closing files
From: Peter Montgomery <pjmonty@csi.com>
Date: Thu, 09 Nov 2000 10:30:12 -0800
Sender: owner-tiff@olympiakos.com


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



