[PATCH 3/6] Fix file descriptor leaks

Ondřej Lysoněk olysonek at redhat.com
Mon Jul 30 16:11:09 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 fe58635..475f250 100644
--- a/src/dial.c
+++ b/src/dial.c
@@ -902,6 +902,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) {
@@ -937,12 +938,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;
@@ -951,6 +954,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;
@@ -958,6 +962,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