Mercurial > octave-libtiff
changeset 31192:6a2bb6f4e41e
__tiff__.cc (F__tiff_imread__): fixed bug where file was not closed on errors.
author | magedrifaat <magedrifaat@gmail.com> |
---|---|
date | Sat, 27 Aug 2022 16:23:59 +0200 |
parents | 8ada1e68d961 |
children | c142c153034c |
files | libinterp/corefcn/__tiff__.cc scripts/image/PKG_ADD |
diffstat | 2 files changed, 10 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- 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;
--- 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