summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEven Rouault <even.rouault@spatialys.com>2021-12-05 14:13:07 +0000
committerEven Rouault <even.rouault@spatialys.com>2021-12-05 14:13:07 +0000
commit2f0187098d3a52f960112a84240cf0eede69a5ff (patch)
tree3289f48262323fe33f48d4b3a00865f796ea8579
parentb09f7e744e77ba24522a1ce92b8297f3383060b9 (diff)
parent5d17d4cc2a4aec4eda5df46ad2ceff01d070d4cd (diff)
downloadlibtiff-git-2f0187098d3a52f960112a84240cf0eede69a5ff.tar.gz
Merge branch 'b1' into 'master'
Fix resource leak on error path See merge request libtiff/libtiff!263
-rw-r--r--archive/tools/ras2tiff.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/archive/tools/ras2tiff.c b/archive/tools/ras2tiff.c
index 30104f06..d3ae889d 100644
--- a/archive/tools/ras2tiff.c
+++ b/archive/tools/ras2tiff.c
@@ -163,11 +163,15 @@ main(int argc, char* argv[])
buf = (unsigned char *)_TIFFmalloc(h.ras_maplength);
if (buf == NULL) {
fprintf(stderr, "No space to read in colormap.\n");
+ fclose(in);
+ (void) TIFFClose(out);
return (-5);
}
if (fread(buf, h.ras_maplength, 1, in) != 1) {
fprintf(stderr, "%s: Read error on colormap.\n",
argv[optind]);
+ fclose(in);
+ (void) TIFFClose(out);
return (-6);
}
mapsize = 1<<h.ras_depth;
@@ -175,11 +179,15 @@ main(int argc, char* argv[])
fprintf(stderr,
"%s: Huh, %d colormap entries, should be %d?\n",
argv[optind], h.ras_maplength, mapsize*3);
+ fclose(in);
+ (void) TIFFClose(out);
return (-7);
}
red = (uint16_t*)_TIFFmalloc(mapsize * 3 * sizeof (uint16_t));
if (red == NULL) {
fprintf(stderr, "No space for colormap.\n");
+ fclose(in);
+ (void) TIFFClose(out);
return (-8);
}
map = red;