summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbonniegong <yuanjungong96@gmail.com>2021-12-05 14:13:07 +0000
committerEven Rouault <even.rouault@spatialys.com>2021-12-05 14:13:07 +0000
commit5d17d4cc2a4aec4eda5df46ad2ceff01d070d4cd (patch)
treee077e56a3e9eaa45a64c9e2ae6b30bbc9d2b1279
parentc67e182128f258fdd580affc3511caf7ddf8f99c (diff)
downloadlibtiff-git-5d17d4cc2a4aec4eda5df46ad2ceff01d070d4cd.tar.gz
rast2tiff: Fix resource leak on error path
-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;