cookie_list->RemoveElementAt(i);
cookie_list->RemoveElementAt(i--);
COOKIE_GetCookie(char * address) {  char *name=0;  cookie_CookieStruct * cookie_s;  PRBool isSecure = PR_FALSE;  time_t cur_time = get_current_time();  int host_length;  /* return string to build */  char * rv=0;  /* disable cookies if the user's prefs say so */  if(cookie_GetBehaviorPref() == PERMISSION_DontUse) {    return NULL;  }  if (!PL_strncasecmp(address, "https", 5)) {     isSecure = PR_TRUE;  }  /* search for all cookies */  if (cookie_list == nsnull) {    return NULL;  }  char *host = CKutil_ParseURL(address, GET_HOST_PART);  char *path = CKutil_ParseURL(address, GET_PATH_PART);  for (PRInt32 i = 0; i <cookie_list->Count(); i++) {    cookie_s = NS_STATIC_CAST(cookie_CookieStruct*, cookie_list->ElementAt(i));    NS_ASSERTION(cookie_s, "corrupt cookie list");    if(!cookie_s->host) continue;    /* check the host or domain first */    if(cookie_s->isDomain) {      char *cp;      /* calculate the host length by looking at all characters up to a       * colon or '\0'.  That way we won't include port numbers in domains       */      for(cp=host; *cp != '\0' && *cp != ':'; cp++) {        ; /* null body */       }      host_length = cp - host;      if(!cookie_IsInDomain(cookie_s->host, host, host_length)) {        continue;      }    } else if(PL_strcasecmp(host, cookie_s->host)) {      /* hostname matchup failed. FAIL */      continue;    }    /* shorter strings always come last so there can be no ambiquity */    if(cookie_s->path && !PL_strncmp(path, cookie_s->path, PL_strlen(cookie_s->path))) {      /* if the cookie is secure and the path isn't, dont send it */      if (cookie_s->isSecure & !isSecure) {        continue; /* back to top of while */      }      /* check for expired cookies */      if( cookie_s->expires && (cookie_s->expires < cur_time) ) {        /* expire and remove the cookie */        cookie_list->RemoveElementAt(i);        deleteCookie((void*)cookie_s, nsnull);        cookie_changed = PR_TRUE;        continue;      }      /* if we've already added a cookie to the return list, append a "; " so       * subsequent cookies are delimited in the final list. */      if (rv) CKutil_StrAllocCat(rv, "; ");      if(cookie_s->name && *cookie_s->name != '\0') {        cookie_s->lastAccessed = cur_time;        CKutil_StrAllocCopy(name, cookie_s->name);        CKutil_StrAllocCat(name, "=");#ifdef PREVENT_DUPLICATE_NAMES        /* make sure we don't have a previous name mapping already in the string */        if(!rv || !PL_strstr(rv, name)) {          CKutil_StrAllocCat(rv, name);          CKutil_StrAllocCat(rv, cookie_s->cookie);        }#else        CKutil_StrAllocCat(rv, name);        CKutil_StrAllocCat(rv, cookie_s->cookie);#endif /* PREVENT_DUPLICATE_NAMES */      } else {        CKutil_StrAllocCat(rv, cookie_s->cookie);      }    }  }  PR_FREEIF(name);  PR_FREEIF(path);  PR_FREEIF(host);  /* may be NULL */  return(rv);}