This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU Mailutils".

http://git.savannah.gnu.org/cgit/mailutils.git/commit/?id=c0920d67832b696e263bf20091b0652fe52491aa

The branch, master has been updated
       via  c0920d67832b696e263bf20091b0652fe52491aa (commit)
      from  8b2f66dd690b7d45e92dbeb5e2900bca0b3d1a16 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit c0920d67832b696e263bf20091b0652fe52491aa
Author: Sergey Poznyakoff <g...@gnu.org.ua>
Date:   Mon Jul 4 12:16:43 2016 +0300

    Fix memory allocation in libmu_imap
    
    * libproto/imap/tag.c (_mu_imap_tag_incr): Fix size calculation when
    reallocating tag_buf
    (_mu_imap_tag_clr): Re-initialize members on error.

-----------------------------------------------------------------------

Summary of changes:
 libproto/imap/tag.c |   13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/libproto/imap/tag.c b/libproto/imap/tag.c
index 2f4f794..73a0eda 100644
--- a/libproto/imap/tag.c
+++ b/libproto/imap/tag.c
@@ -35,11 +35,13 @@ _mu_imap_tag_incr (mu_imap_t imap)
       if (++i == imap->tag_len)
        {
          char *sp;
-         int *np = realloc (imap->tag_buf, imap->tag_len + 1);
+         int *np = realloc (imap->tag_buf,
+                            (imap->tag_len + 1) * sizeof imap->tag_buf[0]);
          if (!np)
            return ENOMEM;
          imap->tag_buf = np;
-         sp = realloc (imap->tag_str, imap->tag_len + 2);
+         sp = realloc (imap->tag_str,
+                       (imap->tag_len + 2) * sizeof imap->tag_str[0]);
          if (!sp)
            return ENOMEM;
          imap->tag_str = sp;
@@ -69,11 +71,16 @@ _mu_imap_tag_clr (mu_imap_t imap)
       imap->tag_len = 2;
       imap->tag_buf = calloc (imap->tag_len, sizeof (imap->tag_buf[0]));
       if (!imap->tag_buf)
-       return ENOMEM;
+       {
+         imap->tag_len = 0;
+         return ENOMEM;
+       }
       imap->tag_str = calloc (imap->tag_len + 1, sizeof (imap->tag_str[0]));
       if (!imap->tag_str)
        {
          free (imap->tag_buf);
+         imap->tag_buf = NULL;
+         imap->tag_len = 0;
          return ENOMEM;
        }
     }


hooks/post-receive
-- 
GNU Mailutils

_______________________________________________
Commit-mailutils mailing list
Commit-mailutils@gnu.org
https://lists.gnu.org/mailman/listinfo/commit-mailutils

Reply via email to