# HG changeset patch # User magedrifaat # Date 1661610239 -7200 # Node ID 6a2bb6f4e41ebb1213182eab0a063fdaa866ced0 # Parent 8ada1e68d9613f2de55def3242640b10d0303a35 __tiff__.cc (F__tiff_imread__): fixed bug where file was not closed on errors. diff -r 8ada1e68d961 -r 6a2bb6f4e41e libinterp/corefcn/__tiff__.cc --- a/libinterp/corefcn/__tiff__.cc Fri Aug 26 23:30:55 2022 +0200 +++ b/libinterp/corefcn/__tiff__.cc Sat Aug 27 16:23:59 2022 +0200 @@ -3557,6 +3557,13 @@ uint16_t offset = 1; TIFF *tif = TIFFOpen (args(0).string_value ().c_str (), "r"); + if (! tif) + error ("Failed to open file %s", args(0).string_value ().c_str ()); + + // A simple way to make sure the file will be closed when the function + // returns or when an error occurs as the destructor will always be called + octave_tiff_handle tiff_handle (tif); + uint16_t dir_count = TIFFNumberOfDirectories (tif); uint16_t page = 1; @@ -3612,11 +3619,11 @@ // Set the default region uint32NDArray row_region (dim_vector (1, 3)); - row_region(0) = 0; + row_region(0) = 1; row_region(1) = 1; row_region(2) = image_data.height; uint32NDArray col_region (dim_vector (1, 3)); - col_region(0) = 0; + col_region(0) = 1; col_region(1) = 1; col_region(2) = image_data.width; diff -r 8ada1e68d961 -r 6a2bb6f4e41e scripts/image/PKG_ADD --- a/scripts/image/PKG_ADD Fri Aug 26 23:30:55 2022 +0200 +++ b/scripts/image/PKG_ADD Sat Aug 27 16:23:59 2022 +0200 @@ -1,7 +1,7 @@ if __have_feature__ ("TIFF") format = imformats("tif"); format.read = @__tiff_imread__; - format.write = @__tiff_imwrite__; + format.write = @__imwrite__; format.info = @__tiff_imfinfo__; imformats("update", "tif", format); endif \ No newline at end of file