lynx-dev
[Top][All Lists]
Advanced

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

Re: lynx-dev [dev17] More cookie crumbs ... [patch]


From: brian j pardy
Subject: Re: lynx-dev [dev17] More cookie crumbs ... [patch]
Date: Fri, 19 Feb 1999 18:53:51 -0800

On Fri, Feb 19, 1999, Kim DeVaughn wrote:
> Looks like -dev.17 has picked up a few new cookie-related memory
> leaks:
> 
>  >Memory leak detected.
>  >Pointer:    0x1631c0
>  >Contains::  |
>  >ByteSize:   1
>  >FileName:   ./LYCookie.c
>  >LineCount:  2674
[...]
> which appear to be a missing FREE() for the StrAllocCopy() noted in
> this code fragment from LYCookie.c:2645;
> 
>  >/*      cookie_domain_flag_set
>  >**      ----------------------
>  >**      All purpose function to handle setting domain flags for a
>  >**      comma-delimited list of domains.  cookie_domain_flags handles
>  >**      invcheck behavior, as well as accept/reject behavior. - BJP
>  >*/
>  >
>  >PUBLIC void cookie_domain_flag_set ARGS2(
>  >        char *,         domainstr,
>  >        int,    flag)
>  >{
>  >    domain_entry *de = NULL;
>  >    domain_entry *de2 = NULL;
>  >    HTList *hl = NULL;
>  >    char *dstr = NULL;
>  >    char *strsmall = NULL;
>  >    int isexisting = FALSE;
>  >
>  >    /*
>  >     * Is this the first domain we're handling?  If so, initialize
>  >     * domain_list.
>  >     */
>  >
>  >    if (domain_list == NULL) {
>  >        atexit(LYCookieJar_free);
>  >        domain_list = HTList_new();
>  >        total_cookies = 0;
>  >    }
>  >
> ===>  StrAllocCopy(dstr, domainstr); <===[**** cookie crumb maker (?) ****]
>  >
>  >    while ((strsmall = LYstrsep(&dstr, ",")) != 0) {
>  >
>  >        /*
>  >         * Check the list of existing domains to see if this is a
>  >         * re-setting of an already existing domains -- if so, just
>  >         * change the behavior, if not, create a new domain entry.
>  >         */
>  >
>  >        for (hl = domain_list; hl != NULL; hl = hl->next) {
>  >            de2 = (domain_entry *)hl->object;
>  >            if ((de2 != NULL && de2->domain != NULL) &&
>  >                !strcmp(strsmall, de2->domain)) {
>  >                        isexisting = TRUE;
>  >                        break;
>  >            } else {
>  >                isexisting = FALSE;

Going through that LYstrsep() was changing dstr, which made it so the
FREE() that was at the end of the function wasn't free'ing the entire
bit of reserved memory.

This patch halfway reverses a change I made for dev.17 without testing
well enough.  It still saves a bit of memory as the dev.17 change did,
but I had to re-add a pointer I thought I could blow away, having
forgotten how LYstrsep() worked.

> Am I the only one who runs with  --enable-find-leaks  on, while doing
> development ...?

I try to do it every few versions that I make changes, and then I did
it a bit more once we hit the pre* patches for 2.8.1 as opposed to
dev*.



diff -cr 2.8.2dev.17/src/LYCookie.c 2.8.2dev.17.bri/src/LYCookie.c
*** 2.8.2dev.17/src/LYCookie.c  Wed Feb 17 06:29:33 1999
--- 2.8.2dev.17.bri/src/LYCookie.c      Fri Feb 19 18:41:53 1999
***************
*** 2656,2665 ****
--- 2656,2669 ----
      domain_entry *de = NULL;
      domain_entry *de2 = NULL;
      HTList *hl = NULL;
+     char **str = (char **)calloc(1, sizeof(domainstr));
      char *dstr = NULL;
      char *strsmall = NULL;
      int isexisting = FALSE;
  
+     if (str == NULL)
+         outofmem(__FILE__, "cookie_set_invcheck");
+ 
      /*
       * Is this the first domain we're handling?  If so, initialize
       * domain_list.
***************
*** 2673,2679 ****
  
      StrAllocCopy(dstr, domainstr);
  
!     while ((strsmall = LYstrsep(&dstr, ",")) != 0) {
  
        /*
         * Check the list of existing domains to see if this is a
--- 2677,2685 ----
  
      StrAllocCopy(dstr, domainstr);
  
!     *str = dstr;
! 
!     while ((strsmall = LYstrsep(str, ",")) != 0) {
  
        /*
         * Check the list of existing domains to see if this is a
***************
*** 2746,2751 ****
--- 2752,2758 ----
      }
  
      FREE(strsmall);
+     FREE(str);
      FREE(dstr);
  }
  

-- 
Swap read error.  You lose your mind.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]