2020.07.17 13:01 "Re: [Tiff] Fw: program crashing when using TIFFClientOpen API during closing the file.", by Bob Friesenhahn
Thanks Bob. We can use valgrind to check.
If we use thandle and allocate memory using 'new', will libtiff free it in _TIFFFree and cause issues? What is the pattern that needs to be followed?
The handle is just an opaque handle and libtiff does not know what it is. Libtiff does not free it.
Since you are allocating some memory using C++ new, it is wise to be very aware that standard C language malloc and C++ new are different memory allocation systems so one must take care to always free using the correct deallocator. Libtiff itself (C library part) only uses malloc/realloc/free. The lifetime of C++ memory allocations may be different than with C since C++ supports destructors.
At one time libtiff only supported 32-bit offsets but since 4.0 it supports 64-bit offsets. With care, a program which properly uses libtiff's typedefs will compile properly for both. When I updated GraphicsMagick for libtiff 4.0, I initially did encounter crashes until I fixed the functions passed to TIFFClientOpen().
This is how I run valgrind:
valgrind --tool=memcheck --leak-check=full --read-var-info=yes --track-origins=yes --num-callers=12 program ...
GraphicsMagick Maintainer, http://www.GraphicsMagick.org/
Public Key, http://www.simplesystems.org/users/bfriesen/public-key.txt