summaryrefslogtreecommitdiff
path: root/src/bin/mj2
diff options
context:
space:
mode:
authorEduardo Barretto <edusbarretto@gmail.com>2020-04-16 19:09:40 -0300
committerGitHub <noreply@github.com>2020-04-17 00:09:40 +0200
commit040e142288e90c9c2d46d25d0a27f828f968bb93 (patch)
tree48d747bb1bcdfa12c4b1cc3105e136e0fbfdb868 /src/bin/mj2
parent221a801a97a3ea968a311f7905c18a1eb7f034c4 (diff)
jp3d/jpwl/mj2/jpip: Fix resource leaks (#1226)
This issues were found by cppcheck and coverity.
Diffstat (limited to 'src/bin/mj2')
-rw-r--r--src/bin/mj2/mj2_to_metadata.c1
-rw-r--r--src/bin/mj2/opj_mj2_compress.c1
-rw-r--r--src/bin/mj2/opj_mj2_decompress.c4
3 files changed, 5 insertions, 1 deletions
diff --git a/src/bin/mj2/mj2_to_metadata.c b/src/bin/mj2/mj2_to_metadata.c
index 44858c86..27f164d7 100644
--- a/src/bin/mj2/mj2_to_metadata.c
+++ b/src/bin/mj2/mj2_to_metadata.c
@@ -304,6 +304,7 @@ int main(int argc, char *argv[])
xmlout = fopen(outfile, "w"); /* was: argv[2] */
if (!xmlout) {
fprintf(stderr, "Failed to open %s for writing.\n", outfile); /* was: argv[2] */
+ fclose(file);
return 1;
}
// Leave it open
diff --git a/src/bin/mj2/opj_mj2_compress.c b/src/bin/mj2/opj_mj2_compress.c
index c61b4c92..8386ba0e 100644
--- a/src/bin/mj2/opj_mj2_compress.c
+++ b/src/bin/mj2/opj_mj2_compress.c
@@ -708,6 +708,7 @@ int main(int argc, char **argv)
yuv_num_frames(&movie->tk[0], mj2_parameters.infile);
if (movie->tk[0].num_samples == 0) {
+ fclose(mj2file);
return 1;
}
diff --git a/src/bin/mj2/opj_mj2_decompress.c b/src/bin/mj2/opj_mj2_decompress.c
index 6b26d563..6d1a9616 100644
--- a/src/bin/mj2/opj_mj2_decompress.c
+++ b/src/bin/mj2/opj_mj2_decompress.c
@@ -99,8 +99,9 @@ int main(int argc, char *argv[])
/* Checking output file */
outfile = fopen(argv[2], "w");
- if (!file) {
+ if (!outfile) {
fprintf(stderr, "failed to open %s for writing\n", argv[2]);
+ fclose(file);
return 1;
}
fclose(outfile);
@@ -169,6 +170,7 @@ int main(int argc, char *argv[])
if ((frame_codestream = (unsigned char*)
realloc(frame_codestream, max_codstrm_size)) == NULL) {
printf("Error reallocation memory\n");
+ free(frame_codestream);
return 1;
};
}