Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/crypto/external/bsd/libsaslc/dist/src Fix various minor memo...



details:   https://anonhg.NetBSD.org/src/rev/b3eee9cfd189
branches:  trunk
changeset: 809890:b3eee9cfd189
user:      shm <shm%NetBSD.org@localhost>
date:      Sat Aug 08 10:38:35 2015 +0000

description:
Fix various minor memory leaks on errors

diffstat:

 crypto/external/bsd/libsaslc/dist/src/xsess.c |  11 ++++++++---
 1 files changed, 8 insertions(+), 3 deletions(-)

diffs (41 lines):

diff -r ede7fd5af058 -r b3eee9cfd189 crypto/external/bsd/libsaslc/dist/src/xsess.c
--- a/crypto/external/bsd/libsaslc/dist/src/xsess.c     Sat Aug 08 08:18:52 2015 +0000
+++ b/crypto/external/bsd/libsaslc/dist/src/xsess.c     Sat Aug 08 10:38:35 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: xsess.c,v 1.7 2013/06/28 15:04:35 joerg Exp $ */
+/* $NetBSD: xsess.c,v 1.8 2015/08/08 10:38:35 shm Exp $ */
 
 /*
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -36,7 +36,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: xsess.c,v 1.7 2013/06/28 15:04:35 joerg Exp $");
+__RCSID("$NetBSD: xsess.c,v 1.8 2015/08/08 10:38:35 shm Exp $");
 
 #include <assert.h>
 #include <saslc.h>
@@ -556,8 +556,10 @@
        ate = 0;
        do {
                len = xxcode(sess, in, inlen, &pkt, &pktlen);
-               if (len == -1)  /* error */
+               if (len == -1) {
+                       free(buf);
                        return -1;
+               }
 
                ate += len;
                in = (const char *)in + len;
@@ -570,7 +572,10 @@
                        continue;
 
                buflen += pktlen;
+               p = buf;
                if ((buf = realloc(buf, buflen)) == NULL) {
+                       /* we should free memory if realloc(2) failed */
+                       free(p);
                        saslc__error_set_errno(ERR(sess), ERROR_NOMEM);
                        return -1;
                }



Home | Main Index | Thread Index | Old Index