ref: 38fc0d59bcad2846b59f21d0cc308e43ea9545b2
parent: a44e95abd0b6892401f1525cf1cd5590f93277de
author: Gregory Maxwell <[email protected]>
date: Sat Oct 29 19:54:45 EDT 2011
Fix some inconsequential file descriptor leaks in the demo tools to silence cppcheck warnings.
--- a/celt/opus_custom_demo.c
+++ b/celt/opus_custom_demo.c
@@ -97,6 +97,7 @@
if (!fout)
{
fprintf (stderr, "Could not open output file %s\n", argv[argc-1]);
+ fclose(fin);
return 1;
}
@@ -104,6 +105,8 @@
if (err != 0)
{
fprintf(stderr, "Failed to create the encoder: %s\n", opus_strerror(err));
+ fclose(fin);
+ fclose(fout);
return 1;
}
dec = opus_custom_decoder_create(mode, channels, &err);
@@ -110,6 +113,8 @@
if (err != 0)
{
fprintf(stderr, "Failed to create the decoder: %s\n", opus_strerror(err));
+ fclose(fin);
+ fclose(fout);
return 1;
}
opus_custom_decoder_ctl(dec, OPUS_GET_LOOKAHEAD(&skip));
--- a/src/opus_demo.c
+++ b/src/opus_demo.c
@@ -312,6 +312,7 @@
if (!fout)
{
fprintf (stderr, "Could not open output file %s\n", argv[argc-1]);
+ fclose(fin);
return EXIT_FAILURE;
}
@@ -321,6 +322,8 @@
if (err != OPUS_OK)
{
fprintf(stderr, "Cannot create encoder: %s\n", opus_strerror(err));
+ fclose(fin);
+ fclose(fout);
return EXIT_FAILURE;
}
opus_encoder_ctl(enc, OPUS_SET_BITRATE(bitrate_bps));
@@ -341,6 +344,8 @@
if (err != OPUS_OK)
{
fprintf(stderr, "Cannot create decoder: %s\n", opus_strerror(err));
+ fclose(fin);
+ fclose(fout);
return EXIT_FAILURE;
}
}
@@ -434,6 +439,8 @@
if (len[toggle] < 0)
{
fprintf (stderr, "opus_encode() returned %d\n", len[toggle]);
+ fclose(fin);
+ fclose(fout);
return EXIT_FAILURE;
}
}
@@ -485,6 +492,8 @@
(long)count,
(unsigned long)enc_final_range[toggle^use_inbandfec],
(unsigned long)dec_final_range);
+ fclose(fin);
+ fclose(fout);
return EXIT_FAILURE;
}
--- a/src/repacketizer_demo.c
+++ b/src/repacketizer_demo.c
@@ -72,6 +72,7 @@
if(fout==NULL)
{
fprintf(stderr, "Error opening output file: %s\n", argv[argc-1]);
+ fclose(fin);
return 1;
}
@@ -94,6 +95,8 @@
eof = 1;
} else {
fprintf(stderr, "Invalid payload length\n");
+ fclose(fin);
+ fclose(fout);
return 1;
}
break;