Fix potential resource leaks
Change-Id: I2e800110cae44baa31abfc0130e84d1598c46781
diff --git a/common/video_writer.c b/common/video_writer.c
index 2b42e36..1d4328a 100644
--- a/common/video_writer.c
+++ b/common/video_writer.c
@@ -41,8 +41,10 @@
if (!file) return NULL;
writer = malloc(sizeof(*writer));
- if (!writer) return NULL;
-
+ if (!writer) {
+ fclose(file);
+ return NULL;
+ }
writer->frame_count = 0;
writer->info = *info;
writer->file = file;
diff --git a/examples/resize_util.c b/examples/resize_util.c
index 6a84d57..5692c20 100644
--- a/examples/resize_util.c
+++ b/examples/resize_util.c
@@ -83,6 +83,7 @@
}
fpout = fopen(fout, "wb");
if (fpout == NULL) {
+ fclose(fpin);
printf("Can't open file %s to write\n", fout);
usage();
return 1;
diff --git a/tools/aom_entropy_optimizer.c b/tools/aom_entropy_optimizer.c
index d57b886..9f529d9 100644
--- a/tools/aom_entropy_optimizer.c
+++ b/tools/aom_entropy_optimizer.c
@@ -271,7 +271,10 @@
FRAME_COUNTS fc;
const size_t bytes = fread(&fc, sizeof(FRAME_COUNTS), 1, statsfile);
- if (!bytes) return 1;
+ if (!bytes) {
+ fclose(statsfile);
+ return 1;
+ }
FILE *const probsfile = fopen("optimized_probs.c", "w");
if (probsfile == NULL) {