Fix a possible small memory leak
authorMike Kelly <mike@pair.com>
Fri, 16 Dec 2011 19:52:20 +0000 (14:52 -0500)
committerMiklos Szeredi <mszeredi@suse.cz>
Tue, 20 Dec 2011 14:33:58 +0000 (15:33 +0100)
sshfs.c

diff --git a/sshfs.c b/sshfs.c
index c5a2434..d0517ff 100644 (file)
--- a/sshfs.c
+++ b/sshfs.c
@@ -1382,16 +1382,20 @@ static int sftp_init_reply_ok(struct buffer *buf, uint32_t *version)
                struct buffer buf2;
 
                buf_init(&buf2, len - 5);
-               if (do_read(&buf2) == -1)
+               if (do_read(&buf2) == -1) {
+                       buf_free(&buf2);
                        return -1;
+               }
 
                do {
                        char *ext;
                        char *extdata;
 
                        if (buf_get_string(&buf2, &ext) == -1 ||
-                           buf_get_string(&buf2, &extdata) == -1)
+                           buf_get_string(&buf2, &extdata) == -1) {
+                               buf_free(&buf2);
                                return -1;
+                       }
 
                        DEBUG("Extension: %s <%s>\n", ext, extdata);
 
@@ -1407,6 +1411,7 @@ static int sftp_init_reply_ok(struct buffer *buf, uint32_t *version)
                            strcmp(extdata, "1") == 0)
                                sshfs.ext_hardlink = 1;
                } while (buf2.len < buf2.size);
+               buf_free(&buf2);
        }
        return 0;
 }