[PATCH 3/7] Fix file descriptor leaks

Ondřej Lysoněk olysonek at redhat.com
Mon Aug 13 13:39:44 BST 2018


Signed-off-by: Ondřej Lysoněk <olysonek at redhat.com>
---
 src/dial.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/src/dial.c b/src/dial.c
index a3337e5..eada5ee 100644
--- a/src/dial.c
+++ b/src/dial.c
@@ -912,6 +912,7 @@ int readdialdir(void)
   if (fread(&dial_ver, sizeof(dial_ver), 1, fp) != 1)
     {
       werror(_("Failed to read dialing directory\n"));
+      fclose(fp);
       return -1;
     }
   if (dial_ver.magic != DIALMAGIC) {
@@ -947,12 +948,14 @@ int readdialdir(void)
           dial_ver.size > sizeof(struct v4_dialent)) {
         werror(_("Phonelist garbled (unknown version?)"));
         dialents = mkstdent();
+        fclose(fp);
         return -1;
       }
       break;
     case 5:
       if (dial_ver.size != sizeof(struct dialent)) {
 	werror(_("Phonelist corrupted"));
+        fclose(fp);
 	return -1;
       }
       break;
@@ -961,6 +964,7 @@ int readdialdir(void)
       // have different size on 32 and 64bit systems
       if (dial_ver.size != sizeof(struct dialent) - sizeof(void *)) {
         werror(_("Phonelist corrupted"));
+        fclose(fp);
         return -1;
       }
       break;
@@ -968,6 +972,7 @@ int readdialdir(void)
       werror(_("Unknown dialing directory version"));
       dendd = 1;
       dialents = mkstdent();
+      fclose(fp);
       return -1;
   }
 
-- 
2.14.4




More information about the minicom-devel mailing list