[gmime] Properly free vstring on error



commit d8b216b88b16e2fc353678dc84cdd0b1092fafae
Author: Jeffrey Stedfast <jestedfa microsoft com>
Date:   Sat Dec 3 12:07:59 2016 -0500

    Properly free vstring on error

 tests/testsuite.c |   12 ++++++------
 1 files changed, 6 insertions(+), 6 deletions(-)
---
diff --git a/tests/testsuite.c b/tests/testsuite.c
index 103606b..68f9522 100644
--- a/tests/testsuite.c
+++ b/tests/testsuite.c
@@ -354,26 +354,26 @@ static int
 is_gpg_modern (void)
 {
        const char vheader[] = "gpg (GnuPG) ";
-       char *vstring;
-       size_t vlen;
+       char *vstring = NULL;
+       size_t vlen = 0;
        FILE *vpipe;
        int ret;
        
        if ((vpipe = popen ("gpg --version", "r")) == NULL)
                return 0;
        
-       vlen = 0;
-       vstring = NULL;
-       
        if (getline (&vstring, &vlen, vpipe) == -1) {
+               free (vstring);
                pclose (vpipe);
                return 0;
        }
        
        pclose (vpipe);
        
-       if (strncmp (vstring, vheader, sizeof (vheader) - 1))
+       if (strncmp (vstring, vheader, sizeof (vheader) - 1)) {
+               free (vstring);
                return 0;
+       }
        
        ret = (vstring[sizeof (vheader) - 1] > '2') ||
                (vstring[sizeof (vheader) - 1] == '2' &&


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]