> > Until this patch the code was buildable with ancient compilers, which > do not support vector::data().
I am sending modified patch. I do not see any reason why would be better to use preprocessor to switch between "&data[0]" and "data.data()". The first form should do same thing on C++11 as on any older C++. To be more correct there should be check whether is vector empty like "data.empty ? NULL : &data[0]" to avoid undefined behaviour but libtiff will return error early in TIFFClientOpen if it sees such invalid tiff with zero width, height or bits_per_pixel so these vectors will never be empty. // MSC before VC11 has no data member, same as BorlandC I wonder who still uses such archaic compilers. Are there systems where there is no other choice? If someone uses Visual Studio 2012 why to not upgrade to higher version with fixed issues. I suppose it has no more support from Microsoft like Windows XP or Vista. Who would not upgrade from Vista? Also Borland was awful compiler. The newest Embarcadero C++Builder should support C++11 (at least there should be option to use clang mode). the "try {} __finally {}" would make the job as well, right? > I'm not sure which of the two you mean. If try/__finally, then it's a > standard thing in C++ (and other languages; maybe the "__finally" > keyword is different for some compilers (this one is used in C++ > Builder), but some form of it is in every C++ compiler for sure). > > There never been "finally" or "__finally" in C++ standard. Probably never will be because idiomatic way how to do this "finalisation" or deposition of resources in C++ is to use RAII. Unlike for example java where you would use finally. http://www.stroustrup.com/bs_faq2.html#finally https://accu.org/index.php/journals/236 Code in that second link really does not look nice. If you meant that Microsoft extension __finally. This is possibly also in clang and gcc but only for Windows target. https://docs.microsoft.com/en-us/cpp/cpp/try-finally-statement?view=vs-2019 You cannot mix it with C++ "try". This would be even worse as podofo would not be buildable on anything but Windows. So you could still use try-catch without __finally to "simulate" it but then you must delete on 2 places: try { ... } catch(?) { delete[] buffer // re-throw that exception } delete[] buffer Or simply put "delete[] buffer" on all relevant places before PODOFO_RAISE_ERROR as is now done with TIFFClose. But C++ way is much better and far less error prone.
image_tiff_leaks_archaic_compilers.patch
Description: Binary data
_______________________________________________ Podofo-users mailing list Podofo-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/podofo-users