openh264 icon indicating copy to clipboard operation
openh264 copied to clipboard

[PATCH] resource leaks in codec/console/enc/src/welsenc.cpp

Open orbitcowboy opened this issue 12 years ago • 2 comments

Please review the attached patch. It fixes two resource leaks in codec/console/enc/src/welsenc.cpp:

diff --git a/codec/console/enc/src/welsenc.cpp b/codec/console/enc/src/welsenc.cpp
index fb0663c..f7b0270 100644
--- a/codec/console/enc/src/welsenc.cpp
+++ b/codec/console/enc/src/welsenc.cpp
@@ -909,11 +909,13 @@ int ProcessEncodingSvcWithParam (ISVCEncoder* pPtrEnc, int argc, char** argv) {
   int iParsedNum = 3;
   if (ParseCommandLine (argc - iParsedNum, argv + iParsedNum, sSvcParam) != 0) {
     printf ("parse pCommand line failed\n");
+    fclose(pFpSrc);
     return 1;
   }

   if (cmResultSuccess != pPtrEnc->Initialize (&sSvcParam, INIT_TYPE_PARAMETER_BASED)) {
     fprintf (stderr, "Encoder Initialization failed!\n");
+    fclose(pFpSrc);
     return 1;
   }

Best regards

Martin Ettl

orbitcowboy avatar Dec 13 '13 15:12 orbitcowboy

+1

Also, fclose(pFpBs)

Even though the files are automatically closed when the program exits, as is the case above, it is good to explicitly do so.

varunbpatil avatar Dec 14 '13 16:12 varunbpatil

I put this into pull request #58 along with the other two patches you submitted. You will get a faster response from more contributors if you issue pull requests yourself for these, but we are happy to have your contributions either way. Thanks.

ethanhugg avatar Dec 16 '13 17:12 ethanhugg