Petter Reinholdtsen wrote:
> I believe there is a minor memory leak in udpkg.  This patch fixes it.
> It will need a review and some testing before it is commited.
> 
> Index: status.c
> ===================================================================
> --- status.c  (revisjon 29314)
> +++ status.c  (arbeidskopi)
> @@ -106,6 +111,8 @@
>               strcat(multiple_lines, " ");
>               strcat(multiple_lines, buf);
>       }
> +     if (NULL != *ml)
> +             free(*ml);
>          *ml = multiple_lines;
>       ungetc(ch, f);
>       return EXIT_SUCCESS;

Hmm, if you look at the callers of read_block(), all of them pass a
pointer to strdup("") in which is silly if we'll always free it. So we
could instead just:

Index: status.c
===================================================================
--- status.c    (revision 29522)
+++ status.c    (working copy)
@@ -143,7 +143,6 @@
                else if (strstr(buf, "Description: ") == buf)
                {
                        p->description = strdup(buf+13);
-                       p->long_description = strdup("");
                        read_block(f, &p->long_description);
                }
 #ifdef DOL18N
@@ -158,7 +157,6 @@
                        buf[14] = '\0';
                        l->language = strdup(buf+12);
                        l->description = strdup(buf+16);
-                       l->long_description = strdup("");
                        read_block(f, &l->long_description);
                         
                }
@@ -198,7 +196,6 @@
                }
                else if (strstr(buf, "Conffiles: ") == buf)
                {
-                        p->conffiles = strdup("");
                        read_block(f, &p->conffiles);
                }
 

-- 
see shy jo

Attachment: signature.asc
Description: Digital signature

Reply via email to