<html lang='en'>
<head>
<meta content='text/html; charset=utf-8' http-equiv='Content-Type'>
<title>
GitLab
</title>
</meta>
</head>
<style>
  img {
    max-width: 100%;
    height: auto;
  }
  p.details {
    font-style:italic;
    color:#777
  }
  .footer p {
    font-size:small;
    color:#777
  }
  pre.commit-message {
    white-space: pre-wrap;
  }
  .file-stats a {
    text-decoration: none;
  }
  .file-stats .new-file {
    color: #090;
  }
  .file-stats .deleted-file {
    color: #B00;
  }
</style>
<body>
<div class='content'>
<h3>Andrew Price pushed to branch master at <a href="https://projects.sucs.org/arthur/mw">Justin Mitchell / mw</a></h3>
<h4>
Commits:
</h4>
<ul>
<li>
<strong><a href="https://projects.sucs.org/arthur/mw/commit/152e0a0cf54ee64155c53adec8e7cced0051fee5">152e0a0c</a></strong>
<div>
<span>by Andrew Price</span>
<i>at 2015-11-14T15:07:03Z</i>
</div>
<pre class='commit-message'>Fix memory leak in add_folder</pre>
</li>
</ul>
<h4>1 changed file:</h4>
<ul>
<li class='file-stats'>
<a href='#diff-0'>
src/client/folders.c
</a>
</li>
</ul>
<h4>Changes:</h4>
<li id='diff-0'>
<a href='https://projects.sucs.org/arthur/mw/commit/152e0a0cf54ee64155c53adec8e7cced0051fee5#diff-0'>
<strong>
src/client/folders.c
</strong>
</a>
<hr>
<pre class="highlight"><code><span style="color: #000000;background-color: #ffdddd">--- a/src/client/folders.c
</span><span style="color: #000000;background-color: #ddffdd">+++ b/src/client/folders.c
</span><span style="color: #aaaaaa">@@ -19,58 +19,57 @@
</span> 
 void add_folder(void)
 {
<span style="color: #000000;background-color: #ffdddd">-        struct folder *new;
</span><span style="color: #000000;background-color: #ddffdd">+   struct folder new;
</span>   int file;
        int yes;
        int folnum = -1;
        char tmp[11];
 
        if (nofolders()) create_folder_file();
<span style="color: #000000;background-color: #ffdddd">-        new=(struct folder *)malloc(sizeof(*new));
</span>   file=openfolderfile(O_RDWR);
        do{
<span style="color: #000000;background-color: #ffdddd">-                yes=get_folder_entry(file,new);
</span><span style="color: #000000;background-color: #ddffdd">+           yes=get_folder_entry(file, &new);
</span>           folnum++;
<span style="color: #000000;background-color: #ffdddd">-        }while (yes && ((new->status)&1));
</span><span style="color: #000000;background-color: #ddffdd">+   }while (yes && ((new.status)&1));
</span>   if (!yes)
        {
                printf(_("Sorry, no space for a new folder.\n"));
                return;
        }
<span style="color: #000000;background-color: #ffdddd">-        if (lseek(file,-(sizeof(*new)),1)<0)
</span><span style="color: #000000;background-color: #ddffdd">+   if (lseek(file, -(sizeof(new)), SEEK_CUR) < 0)
</span>   {
                perror("add_folder (seek)");
                exit(-1);
        }
        printf(_("Create new folder :\n"));
        printf(_("Folder name (%d chars): "),FOLNAMESIZE);
<span style="color: #000000;background-color: #ffdddd">-        get_str(new->name,FOLNAMESIZE);
-       if (*(new->name)==0) return;
</span><span style="color: #000000;background-color: #ddffdd">+   get_str(new.name, FOLNAMESIZE);
+       if (new.name[0] == '\0') return;
</span>   printf(_("Folder topic (%d chars): "),TOPICSIZE);
<span style="color: #000000;background-color: #ffdddd">-        get_str(new->topic,TOPICSIZE);
</span><span style="color: #000000;background-color: #ddffdd">+   get_str(new.topic,TOPICSIZE);
</span>   printf(_("Folder status (not in group) (arwRWpm): "));
        get_str(tmp,10);
<span style="color: #000000;background-color: #ffdddd">-        new->status=folder_stats(tmp,0)|1;
</span><span style="color: #000000;background-color: #ddffdd">+   new.status = folder_stats(tmp,0)|1;
</span>   printf(_("Folder status (in group) (arwRWpm): "));
        get_str(tmp,10);
<span style="color: #000000;background-color: #ffdddd">-        new->g_status=folder_stats(tmp,0)|1;
</span><span style="color: #000000;background-color: #ddffdd">+   new.g_status = folder_stats(tmp,0)|1;
</span>   printf(_("Folder groups (12345678): "));
        get_str(tmp,10);
<span style="color: #000000;background-color: #ffdddd">-        new->groups=folder_groups(tmp,0);
-       new->first=0;
-       new->last=0;
-       printf(_("Creating folder %s - %s\n"),new->name,new->topic);
</span><span style="color: #000000;background-color: #ddffdd">+   new.groups = folder_groups(tmp,0);
+       new.first = 0;
+       new.last = 0;
+       printf(_("Creating folder %s - %s\n"), new.name, new.topic);
</span> 
        auto_subscribe(folnum,true);
        Lock_File(file); /* folder file */
<span style="color: #000000;background-color: #ffdddd">-        if (write(file,new,sizeof(*new))<0)
</span><span style="color: #000000;background-color: #ddffdd">+   if (write(file, &new, sizeof(new)) <  0)
</span>   {
                perror("add_folder");
                exit(0);
        }
        Unlock_File(file);
        close(file);
<span style="color: #000000;background-color: #ffdddd">-        mwlog("FOLDER(CREATED) %s", new->name);
</span><span style="color: #000000;background-color: #ddffdd">+   mwlog("FOLDER(CREATED) %s", new.name);
</span> }
 
 void auto_subscribe(int folnum, int state)
</code></pre>

<br>
</li>

</div>
<div class='footer' style='margin-top: 10px;'>
<p>

<br>
<a href="https://projects.sucs.org/arthur/mw/commit/152e0a0cf54ee64155c53adec8e7cced0051fee5">View it on GitLab</a>
<br>
You're receiving this email because of your account on <a href="https://projects.sucs.org/">projects.sucs.org</a>.
If you'd like to receive fewer emails, you can adjust your notification settings.
<script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","action":{"@type":"ViewAction","name":"View Commit","url":"https://projects.sucs.org/arthur/mw/commit/152e0a0cf54ee64155c53adec8e7cced0051fee5"}}</script>
</p>
</div>
</body>
</html>