PR_Free(buffer);
delete buffer;
net_ReadCookies(){  XP_List * list_ptr;  net_CookieStruct *new_cookie, *tmp_cookie_ptr;  size_t new_len;  nsAutoString * buffer;  Bool added_to_list;  net_ReadCookiePermissions();  nsFileSpec dirSpec;  nsresult rv = cookie_ProfileDirectory(dirSpec);  if (NS_FAILED(rv)) {    return;  }  nsInputFileStream strm(dirSpec + "cookies.txt");  if (!strm.is_open()) {    /* file doesn't exist -- that's not an error */    return;  }  net_lock_cookie_list();  list_ptr = net_cookie_list;  /* format is:   *   * host \t is_domain \t path \t xxx \t expires \t name \t cookie   *   * if this format isn't respected we move onto the next line in the file.   * is_domain is TRUE or FALSE	-- defaulting to FALSE   * xxx is TRUE or FALSE   -- should default to TRUE   * expires is a time_t integer   * cookie can have tabs   */  while (cookie_GetLine(strm,buffer) != -1){    added_to_list = FALSE;    if (buffer->CharAt(0) == '#' || buffer->CharAt(0) == CR ||        buffer->CharAt(0) == LF || buffer->CharAt(0) == 0) {      PR_Free(buffer);      continue;    }    int hostIndex, isDomainIndex, pathIndex, xxxIndex, expiresIndex, nameIndex, cookieIndex;    hostIndex = 0;    if ((isDomainIndex=buffer->Find('\t', hostIndex)+1) == 0 ||        (pathIndex=buffer->Find('\t', isDomainIndex)+1) == 0 ||        (xxxIndex=buffer->Find('\t', pathIndex)+1) == 0 ||        (expiresIndex=buffer->Find('\t', xxxIndex)+1) == 0 ||        (nameIndex=buffer->Find('\t', expiresIndex)+1) == 0 ||        (cookieIndex=buffer->Find('\t', nameIndex)+1) == 0 ) {      PR_Free(buffer);      continue;    }    nsString host, isDomain, path, xxx, expires, name, cookie;    buffer->Mid(host, hostIndex, isDomainIndex-hostIndex-1);    buffer->Mid(isDomain, isDomainIndex, pathIndex-isDomainIndex-1);    buffer->Mid(path, pathIndex, xxxIndex-pathIndex-1);    buffer->Mid(xxx, xxxIndex, expiresIndex-xxxIndex-1);    buffer->Mid(expires, expiresIndex, nameIndex-expiresIndex-1);    buffer->Mid(name, nameIndex, cookieIndex-nameIndex-1);    buffer->Mid(cookie, cookieIndex, buffer->Length()-cookieIndex);    PR_Free(buffer);    /* create a new cookie_struct and fill it in */    new_cookie = PR_NEW(net_CookieStruct);    if (!new_cookie) {      net_unlock_cookie_list();      strm.close();      return;    }    memset(new_cookie, 0, sizeof(net_CookieStruct));    new_cookie->name = name.ToNewCString();    new_cookie->cookie = cookie.ToNewCString();    new_cookie->host = host.ToNewCString();    new_cookie->path = path.ToNewCString();    if (isDomain == "TRUE") {      new_cookie->is_domain = PR_TRUE;    } else {      new_cookie->is_domain = PR_FALSE;    }    if (xxx == "TRUE") {      new_cookie->xxx = PR_TRUE;    } else {      new_cookie->xxx = PR_FALSE;    }    char * expiresCString = expires.ToNewCString();    new_cookie->expires = atol(expiresCString);    delete[] expiresCString;    /* start new cookie list if one does not already exist */    if (!net_cookie_list) {      net_cookie_list = XP_ListNew();      if (!net_cookie_list) {        net_unlock_cookie_list();        strm.close();        return;      }    }    /* add new cookie to the list so that it is before any strings of smaller length */    new_len = PL_strlen(new_cookie->path);    while ((tmp_cookie_ptr = (net_CookieStruct *) XP_ListNextObject(list_ptr)) != NULL) {      if (new_len > PL_strlen(tmp_cookie_ptr->path)) {        XP_ListInsertObject(net_cookie_list, tmp_cookie_ptr, new_cookie);        added_to_list = TRUE;        break;      }    }    /* no shorter strings found in list so add new cookie at end */	    if (!added_to_list) {      XP_ListAddObjectToEnd(net_cookie_list, new_cookie);    }  }  strm.close();  net_unlock_cookie_list();  cookies_changed = FALSE;  return;}